pub trait FileConfig: Sized + Send + Sync + Unpin + 'static {
    type Metadata: Serialize + DeserializeOwned + Send + Sync + Debug + Clone;

    const BLOCK_SIZE: usize;
Show 23 methods // Required methods fn files_name() -> CollectionName; fn blocks_name() -> CollectionName; // Provided methods fn register_collections(schema: &mut Schematic) -> Result<(), Error> { ... } fn build<NameOrPath: AsRef<str>>( name_or_path: NameOrPath ) -> FileBuilder<'static, Self> where Self::Metadata: Default { ... } fn build_with_metadata<NameOrPath: AsRef<str>>( name_or_path: NameOrPath, metadata: Self::Metadata ) -> FileBuilder<'static, Self> { ... } fn get<Database: Connection + Clone>( id: u32, database: &Database ) -> Result<Option<File<Blocking<Database>, Self>>, Error> { ... } fn load<Database: Connection + Clone>( path: &str, database: &Database ) -> Result<Option<File<Blocking<Database>, Self>>, Error> { ... } fn load_or_create<Database: Connection + Clone>( path: &str, expect_present: bool, database: &Database ) -> Result<File<Blocking<Database>, Self>, Error> where Self::Metadata: Default { ... } fn load_or_create_with_metadata<Database: Connection + Clone>( path: &str, metadata: Self::Metadata, expect_present: bool, database: &Database ) -> Result<File<Blocking<Database>, Self>, Error> { ... } fn delete<Database: Connection + Clone>( path: &str, database: &Database ) -> Result<bool, Error> { ... } fn list<Database: Connection + Clone>( path: &str, database: &Database ) -> Result<Vec<File<Blocking<Database>, Self>>, Error> { ... } fn list_recursive<Database: Connection + Clone>( path: &str, database: &Database ) -> Result<Vec<File<Blocking<Database>, Self>>, Error> { ... } fn stats<Database: Connection + Clone>( database: &Database ) -> Result<Statistics, Error> { ... } fn stats_for_path<Database: Connection + Clone>( path: &str, database: &Database ) -> Result<Statistics, Error> { ... } 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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: '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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: '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 Self::Metadata: Default, Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: '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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: '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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: '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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: '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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn stats_async<'life0, 'async_trait, Database>( database: &'life0 Database ) -> Pin<Box<dyn Future<Output = Result<Statistics, Error>> + Send + 'async_trait>> where Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: '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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... }
}
Expand description

A configuration for a set of stored files.

Required Associated Types§

source

type Metadata: Serialize + DeserializeOwned + Send + Sync + Debug + Clone

The type of the metadata stored in File. If you do not need to store metadata, you can set this type to ().

Required Associated Constants§

source

const BLOCK_SIZE: usize

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.

Required Methods§

source

fn files_name() -> CollectionName

Returns the unique collection name to use to store Files.

source

fn blocks_name() -> CollectionName

Returns the unique collection name to use to store file blocks.

Provided Methods§

source

fn register_collections(schema: &mut Schematic) -> Result<(), Error>

Registers the collections for this configuration into schema.

source

fn build<NameOrPath: AsRef<str>>( name_or_path: NameOrPath ) -> FileBuilder<'static, Self>
where Self::Metadata: Default,

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: AsRef<str>>( 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: Connection + Clone>( id: u32, database: &Database ) -> Result<Option<File<Blocking<Database>, Self>>, Error>

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: Connection + Clone>( path: &str, database: &Database ) -> Result<Option<File<Blocking<Database>, Self>>, Error>

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: Connection + Clone>( path: &str, expect_present: bool, database: &Database ) -> Result<File<Blocking<Database>, Self>, Error>
where Self::Metadata: Default,

Returns the file locate at path, or creates an empty file if not currently present.

If expect_present is true, this function will first check for an existing file before attempting to create the file. This parameter is purely an optimization, and the function will work regardless of the value. Pass true if you expect the file to be present a majority of the time this function is invoked. For example, using this function to retrieve a file created once and append to the same path in the future, passing true will make this function slightly more optimized for the most common flow.

Regardless whether expect_present is true or false, this function will proceed by attempting to create a file at path, relying on BonsaiDb’s ACID-compliance to notify of a conflict if another request succeeds before this one. If a conflict occurs, this function will then attempt to load the document. If the document has been deleted, the Error::Deleted will be returned.

source

fn load_or_create_with_metadata<Database: Connection + Clone>( path: &str, metadata: Self::Metadata, 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.

If expect_present is true, this function will first check for an existing file before attempting to create the file. This parameter is purely an optimization, and the function will work regardless of the value. Pass true if you expect the file to be present a majority of the time this function is invoked. For example, using this function to retrieve a file created once and append to the same path in the future, passing true will make this function slightly more optimized for the most common flow.

Regardless whether expect_present is true or false, this function will proceed by attempting to create a file at path, relying on BonsaiDb’s ACID-compliance to notify of a conflict if another request succeeds before this one. If a conflict occurs, this function will then attempt to load the document. If the document has been deleted, the Error::Deleted will be returned.

source

fn delete<Database: Connection + Clone>( path: &str, database: &Database ) -> Result<bool, Error>

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: Connection + Clone>( path: &str, database: &Database ) -> Result<Vec<File<Blocking<Database>, Self>>, Error>

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.

This function only loads metadata about the files, it does not load the contents of the files.

source

fn list_recursive<Database: Connection + Clone>( path: &str, database: &Database ) -> Result<Vec<File<Blocking<Database>, Self>>, Error>

Returns all files that have a path starting with path.

This function only loads metadata about the files, it does not load the contents of the files.

source

fn stats<Database: Connection + Clone>( database: &Database ) -> Result<Statistics, Error>

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: Connection + Clone>( path: &str, database: &Database ) -> Result<Statistics, Error>

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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: '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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: '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 Self::Metadata: Default, Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns the file locate at path, or creates an empty file if not currently present.

If expect_present is true, this function will first check for an existing file before attempting to create the file. This parameter is purely an optimization, and the function will work regardless of the value. Pass true if you expect the file to be present a majority of the time this function is invoked. For example, using this function to retrieve a file created once and append to the same path in the future, passing true will make this function slightly more optimized for the most common flow.

Regardless whether expect_present is true or false, this function will proceed by attempting to create a file at path, relying on BonsaiDb’s ACID-compliance to notify of a conflict if another request succeeds before this one. If a conflict occurs, this function will then attempt to load the document. If the document has been deleted, the Error::Deleted will be returned.

source

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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns the file locate at path, or creates an empty file if not currently present.

If expect_present is true, this function will first check for an existing file before attempting to create the file. This parameter is purely an optimization, and the function will work regardless of the value. Pass true if you expect the file to be present a majority of the time this function is invoked. For example, using this function to retrieve a file created once and append to the same path in the future, passing true will make this function slightly more optimized for the most common flow.

Regardless whether expect_present is true or false, this function will proceed by attempting to create a file at path, relying on BonsaiDb’s ACID-compliance to notify of a conflict if another request succeeds before this one. If a conflict occurs, this function will then attempt to load the document. If the document has been deleted, the Error::Deleted will be returned.

source

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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: '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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: '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.

This function only loads metadata about the files, it does not load the contents of the files.

source

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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns all files that have a path starting with path.

This function only loads metadata about the files, it does not load the contents of the files.

source

fn stats_async<'life0, 'async_trait, Database>( database: &'life0 Database ) -> Pin<Box<dyn Future<Output = Result<Statistics, Error>> + Send + 'async_trait>>
where Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: '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 Database: 'async_trait + AsyncConnection + Clone, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns statistics for all files whose path starts with path.

Object Safety§

This trait is not object safe.

Implementors§