// Function to insert a blurhash struct into the database
// TODO: error handling everywhere
Function to insert a blurhash struct into the database
TODO: error handling everywhere
Function to insert a blurhash struct into the database TODO : error handling everywhere
fn insert_blurhash(entry: BlurhashCache, keyspace: Keyspace) -> Result<(), String> {
    let db = open_database().unwrap();
    let tree = db.open_tree(keyspace.to_str()).unwrap(); // Open the keyspace
    // Serialize the blurhash struct
    let bytes;
    match bincode::encode_to_vec(&entry, bincode::config::standard()) {
        Ok(result) => bytes = result,
        Err(error) => {
            return Err(error.to_string());
        }
    }
    // Insert it into the database
    match tree.insert(&entry.mxc, bytes) {
        Ok(_) => debug!("inserted blurhash: {}", &entry.mxc),
        Err(error) => error!("couldn't insert blurhash: {}", error),
    }
    return Ok(());
}
fn insert_blurhash ( entry : BlurhashCache , keyspace : Keyspace ) -> Result < ( ) , String > { let db = open_database ( ) . unwrap ( ) ; let tree = db . open_tree ( keyspace . to_str ( ) ) . unwrap ( ) ; // Open the keyspace // Serialize the blurhash struct let bytes ; match bincode :: encode_to_vec ( & entry , bincode :: config :: standard ( ) ) { Ok ( result ) => bytes = result , Err ( error ) => { return Err ( error . to_string ( ) ) ; } } // Insert it into the database match tree . insert ( & entry . mxc , bytes ) { Ok ( _ ) => debug ! ( " " entry mxc ) , Err ( error ) => error ! ( " " error ) , } return Ok ( ( ) ) ; }
Function to insert a blurhash struct into the database
TODO: error handling everywhere
Function to insert a blurhash struct into the database TODO : error handling everywhere
entry
BlurhashCache
keyspace
Keyspace