aptos-move/framework/move-stdlib/doc/bcs.md
<a id="0x1_bcs"></a>
0x1::bcsUtility for converting a Move value to its binary representation in BCS (Binary Canonical Serialization). BCS is the binary encoding for Move resources and other non-module values published on-chain. See https://github.com/aptos-labs/bcs#binary-canonical-serialization-bcs for more details on BCS.
<pre><code><b>use</b> <a href="option.md#0x1_option">0x1::option</a>; </code></pre><a id="0x1_bcs_to_bytes"></a>
to_bytesNote: all natives would fail if the MoveValue contains a permissioned signer in it. Returns the binary representation of <code>v</code> in BCS (Binary Canonical Serialization) format. Aborts with <code>0x1c5</code> error code if serialization fails.
<pre><code><b>public</b> <b>fun</b> <a href="bcs.md#0x1_bcs_to_bytes">to_bytes</a><MoveValue>(v: &MoveValue): <a href="vector.md#0x1_vector">vector</a><u8> </code></pre> <details> <summary>Implementation</summary> <pre><code><b>native</b> <b>public</b> <b>fun</b> <a href="bcs.md#0x1_bcs_to_bytes">to_bytes</a><MoveValue>(v: &MoveValue): <a href="vector.md#0x1_vector">vector</a><u8>; </code></pre> </details><a id="0x1_bcs_serialized_size"></a>
serialized_sizeReturns the size of the binary representation of <code>v</code> in BCS (Binary Canonical Serialization) format. Aborts with <code>0x1c5</code> error code if there is a failure when calculating serialized size.
<pre><code><b>public</b> <b>fun</b> <a href="bcs.md#0x1_bcs_serialized_size">serialized_size</a><MoveValue>(v: &MoveValue): u64 </code></pre> <details> <summary>Implementation</summary> <pre><code><b>native</b> <b>public</b> <b>fun</b> <a href="bcs.md#0x1_bcs_serialized_size">serialized_size</a><MoveValue>(v: &MoveValue): u64; </code></pre> </details><a id="0x1_bcs_constant_serialized_size"></a>
constant_serialized_sizeIf the type has known constant (always the same, independent of instance) serialized size in BCS (Binary Canonical Serialization) format, returns it, otherwise returns None. Aborts with <code>0x1c5</code> error code if there is a failure when calculating serialized size.
Note: For some types it might not be known they have constant size, and function might return None. For example, signer appears to have constant size, but it's size might change. If this function returned Some() for some type before - it is guaranteed to continue returning Some(). On the other hand, if function has returned None for some type, it might change in the future to return Some() instead, if size becomes "known".
<pre><code><b>public</b> <b>fun</b> <a href="bcs.md#0x1_bcs_constant_serialized_size">constant_serialized_size</a><MoveValue>(): <a href="option.md#0x1_option_Option">option::Option</a><u64> </code></pre> <details> <summary>Implementation</summary> <pre><code><b>native</b> <b>public</b> <b>fun</b> <a href="bcs.md#0x1_bcs_constant_serialized_size">constant_serialized_size</a><MoveValue>(): Option<u64>; </code></pre> </details><a id="@Specification_0"></a>
Native function which is defined in the prover's prelude.
<a id="0x1_bcs_serialize"></a>
<pre><code><b>native</b> <b>fun</b> <a href="bcs.md#0x1_bcs_serialize">serialize</a><MoveValue>(v: &MoveValue): <a href="vector.md#0x1_vector">vector</a><u8>; </code></pre><a id="@Specification_0_serialized_size"></a>
serialized_size<a id="@Specification_0_constant_serialized_size"></a>
constant_serialized_size