pub fn add_file(
        &self,
        key: &str,
        time_stamp: chrono::NaiveDateTime,
        data: &[u8],
    ) -> Result<(), crate::error::Error> {
        let compressed_data: Vec<u8> = Vec::with_capacity(data.len());
        let mut encoder =
            flate2::write::ZlibEncoder::new(compressed_data, flate2::Compression::default());
        encoder.write_all(data)?;
        let compressed_data = encoder.finish()?;

        let time_stamp: i64 = time_stamp.timestamp();

        self.conn.execute(
            DB_INSERT_FILE_QUERY,
            &[
                &key as &dyn ToSql,
                &time_stamp as &dyn ToSql,
                &compressed_data as &dyn ToSql,
            ],
        )?;

        Ok(())
    }
/// Add a file to 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.
/// * data - Is the file contents to store in the database.
///
Add a file to the database.
Add a file to the database .
pub fn add_file(
        &self,
        key: &str,
        time_stamp: chrono::NaiveDateTime,
        data: &[u8],
    ) -> Result<(), crate::error::Error> {
        let compressed_data: Vec<u8> = Vec::with_capacity(data.len());
        let mut encoder =
            flate2::write::ZlibEncoder::new(compressed_data, flate2::Compression::default());
        encoder.write_all(data)?;
        let compressed_data = encoder.finish()?;
        let time_stamp: i64 = time_stamp.timestamp();
        self.conn.execute(
            DB_INSERT_FILE_QUERY,
            &[
                &key as &dyn ToSql,
                &time_stamp as &dyn ToSql,
                &compressed_data as &dyn ToSql,
            ],
        )?;
        Ok(())
    }
pub fn add_file ( & self , key : & str , time_stamp : chrono :: NaiveDateTime , data : & [ u8 ] , ) -> Result < ( ) , crate :: error :: Error > { let compressed_data : Vec < u8 > = Vec :: with_capacity ( data . len ( ) ) ; let mut encoder = flate2 :: write :: ZlibEncoder :: new ( compressed_data , flate2 :: Compression :: default ( ) ) ; encoder . write_all ( data ) ? ; let compressed_data = encoder . finish ( ) ? ; let time_stamp : i64 = time_stamp . timestamp ( ) ; self . conn . execute ( DB_INSERT_FILE_QUERY , & [ & key as & dyn ToSql , & time_stamp as & dyn ToSql , & compressed_data as & dyn ToSql , ] , ) ? ; Ok ( ( ) ) }
Add a file to the database.
Add a file to the database .
&self
key
&str
time_stamp
chrono::NaiveDateTime
data
&[u8]
&self
key
&str
time_stamp
chrono::NaiveDateTime
data
&[u8]