# Trait zebra_chain::serialization::ZcashSerialize

pub trait ZcashSerialize: Sized {
fn zcash_serialize<W: Write>(&self, writer: W) -> Result<(), Error>;

fn zcash_serialize_to_vec(&self) -> Result<Vec<u8>, Error> { ... }
fn zcash_serialized_size(&self) -> usize { ... }
}
Expand description

Consensus-critical serialization for Zcash.

This trait provides a generic serialization for consensus-critical formats, such as network messages, transactions, blocks, etc.

It is intended for use only for consensus-critical formats. Internal serialization can freely use serde, or any other format.

## Required Methods

Write self to the given writer using the canonical format.

This function has a zcash_ prefix to alert the reader that the serialization in use is consensus-critical serialization, rather than some other kind of serialization.

Notice that the error type is std::io::Error; this indicates that serialization MUST be infallible up to errors in the underlying writer. In other words, any type implementing ZcashSerialize must make illegal states unrepresentable.

## Provided Methods

Helper function to construct a vec to serialize the current struct into

Get the size of self by using a fake writer.

## Implementations on Foreign Types

In Transaction V5, SpendAuth signatures are serialized and deserialized in a separate array.

Serialize a Vec as a CompactSize number of items, then the items. This is the most common format in Zcash.

See zcash_serialize_external_count for more details, and usage information.

Write a Bitcoin-encoded UTF-8 &str.

Write a Bitcoin-encoded UTF-8 String.

Serialize an AtLeastOne vector as a CompactSize number of items, then the items. This is the most common format in Zcash.