// Serialize a `MixedHashTree` per the CDDL of the public spec.
// See https://sdk.dfinity.org/docs/interface-spec/index.html#_encoding_of_certificates
Serialize a `MixedHashTree` per the CDDL of the public spec.
Serialize a ` MixedHashTree ` per the CDDL of the public spec .
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
    where
        S: Serializer,
    {
        match self {
            MixedHashTree::Empty => {
                let mut seq = serializer.serialize_seq(Some(1))?;
                seq.serialize_element(&0u8)?;
                seq.end()
            }
            MixedHashTree::Fork(tree) => {
                let mut seq = serializer.serialize_seq(Some(3))?;
                seq.serialize_element(&1u8)?;
                seq.serialize_element(&tree.0)?;
                seq.serialize_element(&tree.1)?;
                seq.end()
            }
            MixedHashTree::Labeled(label, tree) => {
                let mut seq = serializer.serialize_seq(Some(3))?;
                seq.serialize_element(&2u8)?;
                seq.serialize_element(Bytes::new(label.as_bytes()))?;
                seq.serialize_element(&tree)?;
                seq.end()
            }
            MixedHashTree::Leaf(leaf_bytes) => {
                let mut seq = serializer.serialize_seq(Some(2))?;
                seq.serialize_element(&3u8)?;
                seq.serialize_element(Bytes::new(leaf_bytes))?;
                seq.end()
            }
            MixedHashTree::Pruned(digest) => {
                let mut seq = serializer.serialize_seq(Some(2))?;
                seq.serialize_element(&4u8)?;
                seq.serialize_element(Bytes::new(digest.as_bytes()))?;
                seq.end()
            }
        }
    }
fn serialize < S > ( & self , serializer : S ) -> Result < < S as Serializer > :: Ok , < S as Serializer > :: Error > where S : Serializer , { match self { MixedHashTree :: Empty => { let mut seq = serializer . serialize_seq ( Some ( 1 ) ) ? ; seq . serialize_element ( & 0u8 ) ? ; seq . end ( ) } MixedHashTree :: Fork ( tree ) => { let mut seq = serializer . serialize_seq ( Some ( 3 ) ) ? ; seq . serialize_element ( & 1u8 ) ? ; seq . serialize_element ( & tree . 0 ) ? ; seq . serialize_element ( & tree . 1 ) ? ; seq . end ( ) } MixedHashTree :: Labeled ( label , tree ) => { let mut seq = serializer . serialize_seq ( Some ( 3 ) ) ? ; seq . serialize_element ( & 2u8 ) ? ; seq . serialize_element ( Bytes :: new ( label . as_bytes ( ) ) ) ? ; seq . serialize_element ( & tree ) ? ; seq . end ( ) } MixedHashTree :: Leaf ( leaf_bytes ) => { let mut seq = serializer . serialize_seq ( Some ( 2 ) ) ? ; seq . serialize_element ( & 3u8 ) ? ; seq . serialize_element ( Bytes :: new ( leaf_bytes ) ) ? ; seq . end ( ) } MixedHashTree :: Pruned ( digest ) => { let mut seq = serializer . serialize_seq ( Some ( 2 ) ) ? ; seq . serialize_element ( & 4u8 ) ? ; seq . serialize_element ( Bytes :: new ( digest . as_bytes ( ) ) ) ? ; seq . end ( ) } } }
Serialize a `MixedHashTree` per the CDDL of the public spec.
Serialize a ` MixedHashTree ` per the CDDL of the public spec .
&self
serializer
S