pub fn retrieve_file(
        &self,
        key: &str,
        time_stamp: chrono::NaiveDateTime,
    ) -> Result<Option<Vec<u8>>, crate::error::Error> {
        let mut writer = Vec::new();
        let mut deflater = flate2::write::ZlibDecoder::new(writer);

        let time_stamp: i64 = time_stamp.timestamp();

        let bytes: Option<Vec<u8>> = self
            .conn
            .query_row(
                DB_RETRIEVE_FILE_QUERY,
                &[&key as &dyn ToSql, &time_stamp as &dyn ToSql],
                |row| row.get(0),
            )
            .optional()?;

        if let Some(bytes) = bytes {
            deflater.write_all(&bytes[..])?;
            writer = deflater.finish()?;
            Ok(Some(writer))
        } else {
            Ok(None)
        }
    }
/// Retrieve a file from the database.
///
/// # Arguments
///
/// * key - Typically a file name, but it can be any string really. It does not need to be
/// unique for each file in the database.
/// * time_stamp - This is the time stamp you want associated with this entry. This library
/// will not automatically generate time stamps, it is up to the user to decide how they want
/// time stamps generated.
///
/// # Returns
///
/// It returns the content of the file in a buffer. If the database entry was `NULL`, then it
/// returns `None` in the option. If it can't find a file with the correct key and time stamp
/// then it will return an error.
Retrieve a file from the database.
Retrieve a file from the database .
pub fn retrieve_file(
        &self,
        key: &str,
        time_stamp: chrono::NaiveDateTime,
    ) -> Result<Option<Vec<u8>>, crate::error::Error> {
        let mut writer = Vec::new();
        let mut deflater = flate2::write::ZlibDecoder::new(writer);
        let time_stamp: i64 = time_stamp.timestamp();
        let bytes: Option<Vec<u8>> = self
            .conn
            .query_row(
                DB_RETRIEVE_FILE_QUERY,
                &[&key as &dyn ToSql, &time_stamp as &dyn ToSql],
                |row| row.get(0),
            )
            .optional()?;
        if let Some(bytes) = bytes {
            deflater.write_all(&bytes[..])?;
            writer = deflater.finish()?;
            Ok(Some(writer))
        } else {
            Ok(None)
        }
    }
pub fn retrieve_file ( & self , key : & str , time_stamp : chrono :: NaiveDateTime , ) -> Result < Option < Vec < u8 > > , crate :: error :: Error > { let mut writer = Vec :: new ( ) ; let mut deflater = flate2 :: write :: ZlibDecoder :: new ( writer ) ; let time_stamp : i64 = time_stamp . timestamp ( ) ; let bytes : Option < Vec < u8 > > = self . conn . query_row ( DB_RETRIEVE_FILE_QUERY , & [ & key as & dyn ToSql , & time_stamp as & dyn ToSql ] , | row | row . get ( 0 ) , ) . optional ( ) ? ; if let Some ( bytes ) = bytes { deflater . write_all ( & bytes [ .. ] ) ? ; writer = deflater . finish ( ) ? ; Ok ( Some ( writer ) ) } else { Ok ( None ) } }
Retrieve a file from the database.
Retrieve a file from the database .
&self
key
&str
time_stamp
chrono::NaiveDateTime
It returns the content of the file in a buffer. If the database entry was `NULL`, then it
returns `None` in the option. If it can't find a file with the correct key and time stamp
then it will return an error.
It returns the content of the file in a buffer . If the database entry was ` NULL ` then it returns ` None ` in the option . If it can ' t find a file with the correct key and time stamp then it will return an error .
&self
key
&str
time_stamp
chrono::NaiveDateTime