pub struct RedbContainerPartialFetch { /* private fields */ }Expand description
RedbContainerPartialFetch represents an asset fetcher that retrieves asset data
stored in a Redb database.
The fetcher uses the asset’s AssetPath to find the corresponding asset in the database,
reading the data from a specified table in the Redb database.
Implementations§
Source§impl RedbContainerPartialFetch
impl RedbContainerPartialFetch
Sourcepub fn new(database: Database, default_table_name: impl ToString) -> Self
pub fn new(database: Database, default_table_name: impl ToString) -> Self
Creates a new RedbContainerPartialFetch instance using the provided database and default table name.
§Arguments
database: An instance of the RedbDatabaseto use for querying.default_table_name: A string representing the default table name to use for querying.
§Returns
Self: A newRedbContainerPartialFetchinitialized with the given database and table name.
Examples found in repository?
examples/hello_redb.rs (lines 18-21)
10fn main() -> Result<(), Box<dyn Error>> {
11 /* ANCHOR: main */
12 let mut database = AssetDatabase::default()
13 .with_protocol(TextAssetProtocol)
14 .with_protocol(BytesAssetProtocol)
15 .with_protocol(BundleAssetProtocol::new("json", |bytes: Vec<u8>| {
16 Ok((serde_json::from_slice::<Value>(&bytes)?,).into())
17 }))
18 .with_fetch(ContainerAssetFetch::new(RedbContainerPartialFetch::new(
19 Database::create("./resources/database.redb")?,
20 "assets",
21 )));
22
23 let lorem = database.ensure("text://lorem.txt")?;
24 println!("Lorem Ipsum: {}", lorem.access::<&String>(&database));
25
26 let json = database.ensure("json://person.json")?;
27 println!("JSON: {:#}", json.access::<&Value>(&database));
28
29 let trash = database.ensure("bytes://trash.bin")?;
30 println!("Bytes: {:?}", trash.access::<&Vec<u8>>(&database));
31 /* ANCHOR_END: main */
32
33 Ok(())
34}Trait Implementations§
Auto Trait Implementations§
impl Freeze for RedbContainerPartialFetch
impl !RefUnwindSafe for RedbContainerPartialFetch
impl Send for RedbContainerPartialFetch
impl Sync for RedbContainerPartialFetch
impl Unpin for RedbContainerPartialFetch
impl !UnwindSafe for RedbContainerPartialFetch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more