Struct bonsaidb::files::BonsaiFiles
source · pub struct BonsaiFiles;
Expand description
A default configuration for storing files within BonsaiDb.
Trait Implementations§
source§impl Debug for BonsaiFiles
impl Debug for BonsaiFiles
source§impl FileConfig for BonsaiFiles
impl FileConfig for BonsaiFiles
§type Metadata = Option<()>
type Metadata = Option<()>
The type of the
metadata
stored in File
. If you do
not need to store metadata, you can set this type to ()
.source§const BLOCK_SIZE: usize = 65_536usize
const BLOCK_SIZE: usize = 65_536usize
The maximum size for each write to an underlying file. The file will be
stored by breaking the data written into chunks no larger than
BLOCK_SIZE
.source§fn files_name() -> CollectionName
fn files_name() -> CollectionName
Returns the unique collection name to use to store
File
s.source§fn blocks_name() -> CollectionName
fn blocks_name() -> CollectionName
Returns the unique collection name to use to store file blocks.
source§fn register_collections(schema: &mut Schematic) -> Result<(), Error>
fn register_collections(schema: &mut Schematic) -> Result<(), Error>
Registers the collections for this configuration into
schema
.source§fn build<NameOrPath>(name_or_path: NameOrPath) -> FileBuilder<'static, Self>
fn build<NameOrPath>(name_or_path: NameOrPath) -> FileBuilder<'static, Self>
Builds a new file. If
name_or_path
starts with a /
, the argument is
treated as a full path to the file being built. Otherwise, the argument
is treated as the file’s name.source§fn build_with_metadata<NameOrPath>(
name_or_path: NameOrPath,
metadata: Self::Metadata
) -> FileBuilder<'static, Self>
fn build_with_metadata<NameOrPath>( name_or_path: NameOrPath, metadata: Self::Metadata ) -> FileBuilder<'static, Self>
Builds a new file. If
name_or_path
starts with a /
, the argument is
treated as a full path to the file being built. Otherwise, the argument
is treated as the file’s name. The file’s metadata will be metadata
upon creation. The file’s metadata will be metadata
upon creation.source§fn get<Database>(
id: u32,
database: &Database
) -> Result<Option<File<Blocking<Database>, Self>>, Error>where
Database: Connection + Clone,
fn get<Database>(
id: u32,
database: &Database
) -> Result<Option<File<Blocking<Database>, Self>>, Error>where
Database: Connection + Clone,
Returns the file with the unique
id
given, if found. This function
only loads metadata about the file, it does not load the contents of the
file.source§fn load<Database>(
path: &str,
database: &Database
) -> Result<Option<File<Blocking<Database>, Self>>, Error>where
Database: Connection + Clone,
fn load<Database>(
path: &str,
database: &Database
) -> Result<Option<File<Blocking<Database>, Self>>, Error>where
Database: Connection + Clone,
Returns the file located at
path
, if found. This function
only loads metadata about the file, it does not load the contents of the
file.source§fn load_or_create<Database>(
path: &str,
expect_present: bool,
database: &Database
) -> Result<File<Blocking<Database>, Self>, Error>
fn load_or_create<Database>( path: &str, expect_present: bool, database: &Database ) -> Result<File<Blocking<Database>, Self>, Error>
Returns the file locate at
path
, or creates an empty file if not
currently present. Read moresource§fn load_or_create_with_metadata<Database>(
path: &str,
metadata: Self::Metadata,
expect_present: bool,
database: &Database
) -> Result<File<Blocking<Database>, Self>, Error>where
Database: Connection + Clone,
fn load_or_create_with_metadata<Database>(
path: &str,
metadata: Self::Metadata,
expect_present: bool,
database: &Database
) -> Result<File<Blocking<Database>, Self>, Error>where
Database: Connection + Clone,
Returns the file locate at
path
, or creates an empty file if not
currently present. Read moresource§fn delete<Database>(path: &str, database: &Database) -> Result<bool, Error>where
Database: Connection + Clone,
fn delete<Database>(path: &str, database: &Database) -> Result<bool, Error>where
Database: Connection + Clone,
Deletes the file at
path
. Returns true if a file was deleted. Does not
error if the file is not found.source§fn list<Database>(
path: &str,
database: &Database
) -> Result<Vec<File<Blocking<Database>, Self>>, Error>where
Database: Connection + Clone,
fn list<Database>(
path: &str,
database: &Database
) -> Result<Vec<File<Blocking<Database>, Self>>, Error>where
Database: Connection + Clone,
Returns all files that have a containing path of exactly
path
. It will
only return files that have been created, and will not return “virtual”
directories that are part of a file’s path but have never been created. Read moresource§fn list_recursive<Database>(
path: &str,
database: &Database
) -> Result<Vec<File<Blocking<Database>, Self>>, Error>where
Database: Connection + Clone,
fn list_recursive<Database>(
path: &str,
database: &Database
) -> Result<Vec<File<Blocking<Database>, Self>>, Error>where
Database: Connection + Clone,
Returns all files that have a path starting with
path
. Read moresource§fn stats<Database>(database: &Database) -> Result<Statistics, Error>where
Database: Connection + Clone,
fn stats<Database>(database: &Database) -> Result<Statistics, Error>where
Database: Connection + Clone,
Returns statistics for all files contained within this collection. This
is equivalent to calling
Self::stats_for_path
with "/"
for the
path.source§fn stats_for_path<Database>(
path: &str,
database: &Database
) -> Result<Statistics, Error>where
Database: Connection + Clone,
fn stats_for_path<Database>(
path: &str,
database: &Database
) -> Result<Statistics, Error>where
Database: Connection + Clone,
Returns statistics for all files whose path starts with
path
.source§fn get_async<'life0, 'async_trait, Database>(
id: u32,
database: &'life0 Database
) -> Pin<Box<dyn Future<Output = Result<Option<File<Async<Database>, Self>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
fn get_async<'life0, 'async_trait, Database>(
id: u32,
database: &'life0 Database
) -> Pin<Box<dyn Future<Output = Result<Option<File<Async<Database>, Self>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
Returns the file with the unique
id
given, if found. This function
only loads metadata about the file, it does not load the contents of the
file.source§fn load_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<Option<File<Async<Database>, Self>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
fn load_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<Option<File<Async<Database>, Self>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
Returns the file located at
path
, if found. This function
only loads metadata about the file, it does not load the contents of the
file.source§fn load_or_create_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
expect_present: bool,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<File<Async<Database>, Self>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self::Metadata: Default,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
fn load_or_create_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
expect_present: bool,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<File<Async<Database>, Self>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self::Metadata: Default,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
Returns the file locate at
path
, or creates an empty file if not
currently present. Read moresource§fn load_or_create_with_metadata_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
metadata: Self::Metadata,
expect_present: bool,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<File<Async<Database>, Self>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
fn load_or_create_with_metadata_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
metadata: Self::Metadata,
expect_present: bool,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<File<Async<Database>, Self>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
Returns the file locate at
path
, or creates an empty file if not
currently present. Read moresource§fn delete_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
fn delete_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
Deletes the file at
path
. Returns true if a file was deleted. Does not
error if the file is not found.source§fn list_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<Vec<File<Async<Database>, Self>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
fn list_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<Vec<File<Async<Database>, Self>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
Returns all files that have a containing path of exactly
path
. It will
only return files that have been created, and will not return “virtual”
directories that are part of a file’s path but have never been created. Read moresource§fn list_recursive_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<Vec<File<Async<Database>, Self>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
fn list_recursive_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<Vec<File<Async<Database>, Self>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
Returns all files that have a path starting with
path
. Read moresource§fn stats_async<'life0, 'async_trait, Database>(
database: &'life0 Database
) -> Pin<Box<dyn Future<Output = Result<Statistics, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
fn stats_async<'life0, 'async_trait, Database>(
database: &'life0 Database
) -> Pin<Box<dyn Future<Output = Result<Statistics, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
Returns statistics for all files contained within this collection. This
is equivalent to calling
Self::stats_for_path_async
with "/"
for the
path.source§fn stats_for_path_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<Statistics, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
fn stats_for_path_async<'life0, 'life1, 'async_trait, Database>(
path: &'life0 str,
database: &'life1 Database
) -> Pin<Box<dyn Future<Output = Result<Statistics, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Database: 'async_trait + AsyncConnection + Clone,
Self: 'async_trait,
Returns statistics for all files whose path starts with
path
.Auto Trait Implementations§
impl RefUnwindSafe for BonsaiFiles
impl Send for BonsaiFiles
impl Sync for BonsaiFiles
impl Unpin for BonsaiFiles
impl UnwindSafe for BonsaiFiles
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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