pub fn from_asset(
        asset: &Asset,
        connection: &SqliteConnection,
    ) -> Result<Self, SqlCacheError> {
        // Find the last entry and increase index by 1
        let last_asset = sql_asset_table
            .load::<SqlAsset>(connection)?
            .last()
            .cloned();

        Ok(Self {
            id: match last_asset {
                Some(asset) => asset.id + 1,
                None => 0,
            },
            contract_id: asset.id().clone().to_hex(),
            ticker: asset.ticker().clone(),
            asset_name: asset.name().clone(),
            asset_description: asset.description().clone(),
            known_circulating_supply: asset
                .supply()
                .known_circulating()
                .accounting_value()
                as i64,
            is_issued_known: asset.supply().is_issued_known().clone(),
            max_cap: asset.supply().max_cap().accounting_value() as i64,
            chain: asset.chain().to_string(),
            fractional_bits: vec![asset.fractional_bits().clone()],
            asset_date: asset.date().clone(),
        })
    }
/// Create an Sqlite Asset entry from a given Asset data structure.
/// Note, only the metadata are written into the Asset table,
/// All other data for the Asset are to be found from fetching other
/// table entries associated with this Asset entry. So they are implicitly
/// defined in the table schema.   
Create an Sqlite Asset entry from a given Asset data structure.
Note, only the metadata are written into the Asset table,
All other data for the Asset are to be found from fetching other
table entries associated with this Asset entry. So they are implicitly
defined in the table schema.
Create an Sqlite Asset entry from a given Asset data structure . Note only the metadata are written into the Asset table All other data for the Asset are to be found from fetching other table entries associated with this Asset entry . So they are implicitly defined in the table schema .
pub fn from_asset(
        asset: &Asset,
        connection: &SqliteConnection,
    ) -> Result<Self, SqlCacheError> {
        // Find the last entry and increase index by 1
        let last_asset = sql_asset_table
            .load::<SqlAsset>(connection)?
            .last()
            .cloned();
        Ok(Self {
            id: match last_asset {
                Some(asset) => asset.id + 1,
                None => 0,
            },
            contract_id: asset.id().clone().to_hex(),
            ticker: asset.ticker().clone(),
            asset_name: asset.name().clone(),
            asset_description: asset.description().clone(),
            known_circulating_supply: asset
                .supply()
                .known_circulating()
                .accounting_value()
                as i64,
            is_issued_known: asset.supply().is_issued_known().clone(),
            max_cap: asset.supply().max_cap().accounting_value() as i64,
            chain: asset.chain().to_string(),
            fractional_bits: vec![asset.fractional_bits().clone()],
            asset_date: asset.date().clone(),
        })
    }
pub fn from_asset ( asset : & Asset , connection : & SqliteConnection , ) -> Result < Self , SqlCacheError > { // Find the last entry and increase index by 1 let last_asset = sql_asset_table . load :: < SqlAsset > ( connection ) ? . last ( ) . cloned ( ) ; Ok ( Self { id : match last_asset { Some ( asset ) => asset . id + 1 , None => 0 , } , contract_id : asset . id ( ) . clone ( ) . to_hex ( ) , ticker : asset . ticker ( ) . clone ( ) , asset_name : asset . name ( ) . clone ( ) , asset_description : asset . description ( ) . clone ( ) , known_circulating_supply : asset . supply ( ) . known_circulating ( ) . accounting_value ( ) as i64 , is_issued_known : asset . supply ( ) . is_issued_known ( ) . clone ( ) , max_cap : asset . supply ( ) . max_cap ( ) . accounting_value ( ) as i64 , chain : asset . chain ( ) . to_string ( ) , fractional_bits : vec ! [ asset fractional_bits ( ) clone ( ) ] , asset_date : asset . date ( ) . clone ( ) , } ) }
Create an Sqlite Asset entry from a given Asset data structure.
Create an Sqlite Asset entry from a given Asset data structure .
asset
&Asset
connection
&SqliteConnection
asset
&Asset
connection
&SqliteConnection