pub fn write<Size: PageSize>(&self) -> Vec<u8> {
        assert_eq!(
            self.datoms.len() + 1,
            self.children.len(),
            "Node must have one more child than datoms.",
        );
        assert!(
            self.datoms.len() <= Size::CAPACITY,
            "Node has {} datoms, more than a page can hold.", self.datoms.len(),
        );

        let datoms_bytes: &[u8] = unsafe { transmute_slice(self.datoms) };
        let children_bytes: &[u8] = unsafe { transmute_slice(self.children) };

        let mut buffer = Vec::with_capacity(Size::SIZE);

        // First up is the datom array.
        buffer.extend_from_slice(&datoms_bytes);

        // If necessary, pad with zeros between the datom array, and the child
        // page id array.
        let num_zeros = Size::datoms_bytes_len() - datoms_bytes.len();
        buffer.extend((0..num_zeros).map(|_| 0x00));

        // Next up is the child array, also optionally padded.
        buffer.extend_from_slice(&children_bytes);

        let num_zeros = Size::children_bytes_len() - children_bytes.len();
        buffer.extend((0..num_zeros).map(|_| 0x00));

        // Finally, the header. For now it consists of two bytes, and we pad
        // with zeros to fill up the page.
        let header_len = Size::SIZE - Size::header_offset();
        debug_assert!(header_len < 42, "Header too large, could fit extra datom.");
        debug_assert!(header_len >= 2, "Header too small, cannot fit all fields.");
        debug_assert!(self.datoms.len() < 256, "Datoms length must fit in a byte.");
        buffer.push(self.level);              // Header byte 0.
        buffer.push(self.datoms.len() as u8); // Header byte 1.
        let num_zeros = header_len - 2;
        buffer.extend((0..num_zeros).map(|_| 0x00));

        debug_assert_eq!(buffer.len(), Size::SIZE, "Write must fill exactly one page.");

        buffer
    }
/// Serialize the node to bytes, for writing to a store.
Serialize the node to bytes, for writing to a store.
Serialize the node to bytes for writing to a store .
pub fn write<Size: PageSize>(&self) -> Vec<u8> {
        assert_eq!(
            self.datoms.len() + 1,
            self.children.len(),
            "Node must have one more child than datoms.",
        );
        assert!(
            self.datoms.len() <= Size::CAPACITY,
            "Node has {} datoms, more than a page can hold.", self.datoms.len(),
        );
        let datoms_bytes: &[u8] = unsafe { transmute_slice(self.datoms) };
        let children_bytes: &[u8] = unsafe { transmute_slice(self.children) };
        let mut buffer = Vec::with_capacity(Size::SIZE);
        // First up is the datom array.
        buffer.extend_from_slice(&datoms_bytes);
        // If necessary, pad with zeros between the datom array, and the child
        // page id array.
        let num_zeros = Size::datoms_bytes_len() - datoms_bytes.len();
        buffer.extend((0..num_zeros).map(|_| 0x00));
        // Next up is the child array, also optionally padded.
        buffer.extend_from_slice(&children_bytes);
        let num_zeros = Size::children_bytes_len() - children_bytes.len();
        buffer.extend((0..num_zeros).map(|_| 0x00));
        // Finally, the header. For now it consists of two bytes, and we pad
        // with zeros to fill up the page.
        let header_len = Size::SIZE - Size::header_offset();
        debug_assert!(header_len < 42, "Header too large, could fit extra datom.");
        debug_assert!(header_len >= 2, "Header too small, cannot fit all fields.");
        debug_assert!(self.datoms.len() < 256, "Datoms length must fit in a byte.");
        buffer.push(self.level);              // Header byte 0.
        buffer.push(self.datoms.len() as u8); // Header byte 1.
        let num_zeros = header_len - 2;
        buffer.extend((0..num_zeros).map(|_| 0x00));
        debug_assert_eq!(buffer.len(), Size::SIZE, "Write must fill exactly one page.");
        buffer
    }
pub fn write < Size : PageSize > ( & self ) -> Vec < u8 > { assert_eq ! ( self datoms len ( ) 1 self children len ( ) " " ) ; assert ! ( self datoms len ( ) Size CAPACITY " " self datoms len ( ) ) ; let datoms_bytes : & [ u8 ] = unsafe { transmute_slice ( self . datoms ) } ; let children_bytes : & [ u8 ] = unsafe { transmute_slice ( self . children ) } ; let mut buffer = Vec :: with_capacity ( Size :: SIZE ) ; // First up is the datom array. buffer . extend_from_slice ( & datoms_bytes ) ; // If necessary, pad with zeros between the datom array, and the child // page id array. let num_zeros = Size :: datoms_bytes_len ( ) - datoms_bytes . len ( ) ; buffer . extend ( ( 0 .. num_zeros ) . map ( | _ | 0x00 ) ) ; // Next up is the child array, also optionally padded. buffer . extend_from_slice ( & children_bytes ) ; let num_zeros = Size :: children_bytes_len ( ) - children_bytes . len ( ) ; buffer . extend ( ( 0 .. num_zeros ) . map ( | _ | 0x00 ) ) ; // Finally, the header. For now it consists of two bytes, and we pad // with zeros to fill up the page. let header_len = Size :: SIZE - Size :: header_offset ( ) ; debug_assert ! ( header_len 42 " " ) ; debug_assert ! ( header_len 2 " " ) ; debug_assert ! ( self datoms len ( ) 256 " " ) ; buffer . push ( self . level ) ; // Header byte 0. buffer . push ( self . datoms . len ( ) as u8 ) ; // Header byte 1. let num_zeros = header_len - 2 ; buffer . extend ( ( 0 .. num_zeros ) . map ( | _ | 0x00 ) ) ; debug_assert_eq ! ( buffer len ( ) Size SIZE " " ) ; buffer }
Serialize the node to bytes, for writing to a store.
Serialize the node to bytes for writing to a store .
&self
&self