zebra_chain::serialization

Trait ZcashSerialize

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

    // Provided methods
    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§

source

fn zcash_serialize<W: Write>(&self, writer: W) -> Result<(), Error>

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§

source

fn zcash_serialize_to_vec(&self) -> Result<Vec<u8>, Error>

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

source

fn zcash_serialized_size(&self) -> usize

Get the size of self by using a fake writer.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ZcashSerialize for &str

Write a Bitcoin-encoded UTF-8 &str.

source§

fn zcash_serialize<W: Write>(&self, writer: W) -> Result<(), Error>

source§

impl ZcashSerialize for Option<ShieldedData>

source§

fn zcash_serialize<W: Write>(&self, writer: W) -> Result<(), Error>

source§

impl ZcashSerialize for Option<ShieldedData<SharedAnchor>>

source§

fn zcash_serialize<W: Write>(&self, writer: W) -> Result<(), Error>

source§

impl ZcashSerialize for String

Write a Bitcoin-encoded UTF-8 String.

source§

fn zcash_serialize<W: Write>(&self, writer: W) -> Result<(), Error>

source§

impl ZcashSerialize for Ipv6Addr

Write a Bitcoin-encoded IPv6 address.

source§

fn zcash_serialize<W: Write>(&self, writer: W) -> Result<(), Error>

source§

impl ZcashSerialize for PublicKey

source§

fn zcash_serialize<W: Write>(&self, writer: W) -> Result<(), Error>

source§

impl ZcashSerialize for Signature<SpendAuth>

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

source§

fn zcash_serialize<W: Write>(&self, writer: W) -> Result<(), Error>

source§

impl<T> ZcashSerialize for Arc<T>
where T: ZcashSerialize,

source§

fn zcash_serialize<W: Write>(&self, writer: W) -> Result<(), Error>

source§

impl<T: ZcashSerialize> ZcashSerialize for Vec<T>

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.

source§

fn zcash_serialize<W: Write>(&self, writer: W) -> Result<(), Error>

source§

impl<T: SigType> ZcashSerialize for Signature<T>

source§

fn zcash_serialize<W: Write>(&self, writer: W) -> Result<(), Error>

Implementors§

source§

impl ZcashSerialize for Transaction

source§

impl ZcashSerialize for LockTime

source§

impl ZcashSerialize for Address

source§

impl ZcashSerialize for Input

source§

impl ZcashSerialize for Solution

source§

impl ZcashSerialize for Amount<NegativeAllowed>

source§

impl ZcashSerialize for Amount<NonNegative>

source§

impl ZcashSerialize for zebra_chain::block::hash::Hash

source§

impl ZcashSerialize for CountedHeader

source§

impl ZcashSerialize for Header

source§

impl ZcashSerialize for Block

source§

impl ZcashSerialize for Action

source§

impl ZcashSerialize for ValueCommitment

source§

impl ZcashSerialize for zebra_chain::orchard::keys::EphemeralPublicKey

source§

impl ZcashSerialize for zebra_chain::orchard::note::ciphertexts::EncryptedNote

source§

impl ZcashSerialize for zebra_chain::orchard::note::ciphertexts::WrappedNoteKey

source§

impl ZcashSerialize for Flags

source§

impl ZcashSerialize for zebra_chain::orchard::shielded_data::ShieldedData

source§

impl ZcashSerialize for zebra_chain::orchard::tree::Root

source§

impl ZcashSerialize for Bctv14Proof

source§

impl ZcashSerialize for Groth16Proof

source§

impl ZcashSerialize for Halo2Proof

source§

impl ZcashSerialize for NotSmallOrderValueCommitment

source§

impl ZcashSerialize for zebra_chain::sapling::keys::EphemeralPublicKey

source§

impl ZcashSerialize for zebra_chain::sapling::note::ciphertexts::EncryptedNote

source§

impl ZcashSerialize for zebra_chain::sapling::note::ciphertexts::WrappedNoteKey

source§

impl ZcashSerialize for OutputInTransactionV4

source§

impl ZcashSerialize for OutputPrefixInTransactionV5

source§

impl ZcashSerialize for zebra_chain::sapling::shielded_data::ShieldedData<SharedAnchor>

source§

impl ZcashSerialize for Spend<PerSpendAnchor>

source§

impl ZcashSerialize for SpendPrefixInTransactionV5

source§

impl ZcashSerialize for zebra_chain::sapling::tree::Root

source§

impl ZcashSerialize for zebra_chain::sprout::note::ciphertexts::EncryptedNote

source§

impl ZcashSerialize for Mac

source§

impl ZcashSerialize for AuthDigest

source§

impl ZcashSerialize for zebra_chain::transaction::hash::Hash

source§

impl ZcashSerialize for WtxId

source§

impl ZcashSerialize for Script

source§

impl ZcashSerialize for OutPoint

source§

impl ZcashSerialize for Output

source§

impl ZcashSerialize for CompactSize64

source§

impl ZcashSerialize for CompactSizeMessage

source§

impl ZcashSerialize for DateTime32

source§

impl<P: ZkSnarkProof> ZcashSerialize for JoinSplit<P>

source§

impl<P: ZkSnarkProof> ZcashSerialize for JoinSplitData<P>

source§

impl<T: ZcashSerialize> ZcashSerialize for AtLeastOne<T>

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