pub fn insert(&self, entity: &T) -> Result<String> {
        // Serialize the entity.
        let serialized_bytes = serde_json::to_vec(entity).context(FailedToSerializeItem)?;

        // Hash the serialization to get an ID.
        //  (This is the worst way to get an ID - impossible to update)
        //  TODO: Find a better way to handle this.
        let mut hasher = Sha1::new();
        hasher.update(&serialized_bytes);
        let result = hasher.finalize();

        let id_str = format!("{:x}", result);

        self.tree
            .insert(id_str.clone(), serialized_bytes)
            .context(FailedToInsertItem)?;

        Ok(id_str)
    }
/// Insert a new entity to this store.
Insert a new entity to this store.
Insert a new entity to this store .
pub fn insert(&self, entity: &T) -> Result<String> {
        // Serialize the entity.
        let serialized_bytes = serde_json::to_vec(entity).context(FailedToSerializeItem)?;
        // Hash the serialization to get an ID.
        //  (This is the worst way to get an ID - impossible to update)
        //  TODO: Find a better way to handle this.
        let mut hasher = Sha1::new();
        hasher.update(&serialized_bytes);
        let result = hasher.finalize();
        let id_str = format!("{:x}", result);
        self.tree
            .insert(id_str.clone(), serialized_bytes)
            .context(FailedToInsertItem)?;
        Ok(id_str)
    }
pub fn insert ( & self , entity : & T ) -> Result < String > { // Serialize the entity. let serialized_bytes = serde_json :: to_vec ( entity ) . context ( FailedToSerializeItem ) ? ; // Hash the serialization to get an ID. //  (This is the worst way to get an ID - impossible to update) //  TODO: Find a better way to handle this. let mut hasher = Sha1 :: new ( ) ; hasher . update ( & serialized_bytes ) ; let result = hasher . finalize ( ) ; let id_str = format ! ( " " result ) ; self . tree . insert ( id_str . clone ( ) , serialized_bytes ) . context ( FailedToInsertItem ) ? ; Ok ( id_str ) }
Insert a new entity to this store.
Insert a new entity to this store .
&self
entity
&T