async fn serialize<S: SegmentController>(
        &self,
        file: &mut NaivePageController<S>,
        set_root: bool,
    ) -> Result<EntryID> {
        // Behaviour of serialize
        // 1) Calculate the total structure size by summing each field's size.
        // 2) Loop through each field and serialize references to EntryIDs.
        // 3) Get a guard for the total size.
        // 4) Add all the references to the guard.
        // 5) Add all the data.
        // 6) Commit the guard to get a resultant EntryID.
        // The easy way involves an allocation for all of the tuple id's, but we should investigate
        // a way to avoid this. This would basically entail having backing page not borrow file
        // mutably which might be possible through atomics. OTOH we might not want to do this to
        // ensure that we can bound memory resources.
        let mut references = Vec::new();
        let data_length = self.data_length();
        self.serialize_references(file, &mut references).await?;
        let mut guard = file.reserve_space(references.len(), data_length, set_root)?;
        for tuple_id in references.drain(..) {
            guard.add_reference(tuple_id)?;
        }
        self.serialize_data(&mut guard)?;
        Ok(guard.commit())
    }
/// Serializes the object to file.
Serializes the object to file.
Serializes the object to file .
async fn serialize<S: SegmentController>(
        &self,
        file: &mut NaivePageController<S>,
        set_root: bool,
    ) -> Result<EntryID> {
        // Behaviour of serialize
        // 1) Calculate the total structure size by summing each field's size.
        // 2) Loop through each field and serialize references to EntryIDs.
        // 3) Get a guard for the total size.
        // 4) Add all the references to the guard.
        // 5) Add all the data.
        // 6) Commit the guard to get a resultant EntryID.
        // The easy way involves an allocation for all of the tuple id's, but we should investigate
        // a way to avoid this. This would basically entail having backing page not borrow file
        // mutably which might be possible through atomics. OTOH we might not want to do this to
        // ensure that we can bound memory resources.
        let mut references = Vec::new();
        let data_length = self.data_length();
        self.serialize_references(file, &mut references).await?;
        let mut guard = file.reserve_space(references.len(), data_length, set_root)?;
        for tuple_id in references.drain(..) {
            guard.add_reference(tuple_id)?;
        }
        self.serialize_data(&mut guard)?;
        Ok(guard.commit())
    }
async fn serialize < S : SegmentController > ( & self , file : & mut NaivePageController < S > , set_root : bool , ) -> Result < EntryID > { // Behaviour of serialize // 1) Calculate the total structure size by summing each field's size. // 2) Loop through each field and serialize references to EntryIDs. // 3) Get a guard for the total size. // 4) Add all the references to the guard. // 5) Add all the data. // 6) Commit the guard to get a resultant EntryID. // The easy way involves an allocation for all of the tuple id's, but we should investigate // a way to avoid this. This would basically entail having backing page not borrow file // mutably which might be possible through atomics. OTOH we might not want to do this to // ensure that we can bound memory resources. let mut references = Vec :: new ( ) ; let data_length = self . data_length ( ) ; self . serialize_references ( file , & mut references ) . await ? ; let mut guard = file . reserve_space ( references . len ( ) , data_length , set_root ) ? ; for tuple_id in references . drain ( .. ) { guard . add_reference ( tuple_id ) ? ; } self . serialize_data ( & mut guard ) ? ; Ok ( guard . commit ( ) ) }
Serializes the object to file.
Serializes the object to file .
&self
file
&mut NaivePageController<S>
set_root
bool
&self
file
&mut NaivePageController<S>
set_root
bool