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§
sourcefn zcash_serialize<W: Write>(&self, writer: W) -> Result<(), Error>
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§
sourcefn zcash_serialize_to_vec(&self) -> Result<Vec<u8>, Error>
fn zcash_serialize_to_vec(&self) -> Result<Vec<u8>, Error>
Helper function to construct a vec to serialize the current struct into
sourcefn zcash_serialized_size(&self) -> usize
fn zcash_serialized_size(&self) -> usize
Get the size of self
by using a fake writer.
Object Safety§
Implementations on Foreign Types§
source§impl ZcashSerialize for &str
impl ZcashSerialize for &str
Write a Bitcoin-encoded UTF-8 &str
.
source§impl ZcashSerialize for Option<ShieldedData>
impl ZcashSerialize for Option<ShieldedData>
source§impl ZcashSerialize for String
impl ZcashSerialize for String
Write a Bitcoin-encoded UTF-8 String
.
source§impl ZcashSerialize for Ipv6Addr
impl ZcashSerialize for Ipv6Addr
Write a Bitcoin-encoded IPv6 address.
source§impl ZcashSerialize for PublicKey
impl ZcashSerialize for PublicKey
source§impl ZcashSerialize for Signature<SpendAuth>
impl ZcashSerialize for Signature<SpendAuth>
In Transaction V5, SpendAuth signatures are serialized and deserialized in a separate array.
source§impl<T> ZcashSerialize for Arc<T>where
T: ZcashSerialize,
impl<T> ZcashSerialize for Arc<T>where
T: ZcashSerialize,
source§impl<T: ZcashSerialize> ZcashSerialize for Vec<T>
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§impl<T: SigType> ZcashSerialize for Signature<T>
impl<T: SigType> ZcashSerialize for Signature<T>
Implementors§
impl ZcashSerialize for Transaction
impl ZcashSerialize for LockTime
impl ZcashSerialize for Address
impl ZcashSerialize for Input
impl ZcashSerialize for Solution
impl ZcashSerialize for Amount<NegativeAllowed>
impl ZcashSerialize for Amount<NonNegative>
impl ZcashSerialize for zebra_chain::block::hash::Hash
impl ZcashSerialize for CountedHeader
impl ZcashSerialize for Header
impl ZcashSerialize for Block
impl ZcashSerialize for Action
impl ZcashSerialize for ValueCommitment
impl ZcashSerialize for zebra_chain::orchard::keys::EphemeralPublicKey
impl ZcashSerialize for zebra_chain::orchard::note::ciphertexts::EncryptedNote
impl ZcashSerialize for zebra_chain::orchard::note::ciphertexts::WrappedNoteKey
impl ZcashSerialize for Flags
impl ZcashSerialize for zebra_chain::orchard::shielded_data::ShieldedData
impl ZcashSerialize for zebra_chain::orchard::tree::Root
impl ZcashSerialize for Bctv14Proof
impl ZcashSerialize for Groth16Proof
impl ZcashSerialize for Halo2Proof
impl ZcashSerialize for NotSmallOrderValueCommitment
impl ZcashSerialize for zebra_chain::sapling::keys::EphemeralPublicKey
impl ZcashSerialize for zebra_chain::sapling::note::ciphertexts::EncryptedNote
impl ZcashSerialize for zebra_chain::sapling::note::ciphertexts::WrappedNoteKey
impl ZcashSerialize for OutputInTransactionV4
impl ZcashSerialize for OutputPrefixInTransactionV5
impl ZcashSerialize for Spend<PerSpendAnchor>
impl ZcashSerialize for SpendPrefixInTransactionV5
impl ZcashSerialize for zebra_chain::sapling::tree::Root
impl ZcashSerialize for zebra_chain::sprout::note::ciphertexts::EncryptedNote
impl ZcashSerialize for Mac
impl ZcashSerialize for AuthDigest
impl ZcashSerialize for zebra_chain::transaction::hash::Hash
impl ZcashSerialize for WtxId
impl ZcashSerialize for Script
impl ZcashSerialize for OutPoint
impl ZcashSerialize for Output
impl ZcashSerialize for CompactSize64
impl ZcashSerialize for CompactSizeMessage
impl ZcashSerialize for DateTime32
impl<P: ZkSnarkProof> ZcashSerialize for JoinSplit<P>
impl<P: ZkSnarkProof> ZcashSerialize for JoinSplitData<P>
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.