pub trait Files:
Send
+ Sync
+ 'static {
// Required methods
fn write_file(&self, name: &str, bytes: &[u8]) -> Result<()>;
fn append_file(&self, name: &str, bytes: &[u8]) -> Result<()>;
fn read_file(&self, name: &str) -> Result<Vec<u8>>;
fn remove_file(&self, name: &str) -> Result<()>;
fn files(&self) -> Result<Vec<String>>;
}Expand description
A place that keeps files by name, such as a session’s plugin data or
effect log. A name is relative and /-separated (check_name).
Every method takes &self, so one value is shared, between threads on
every target: a host keeps it as Arc<dyn Files> or Arc<dyn Store>
in state its systems share, such as a Bevy resource, which is Send
and Sync on wasm too; Arc<dyn Store> and Box<dyn Store> are
themselves a Store, so an AsyncStore too. A store that is not
Send and Sync, such as one over a JavaScript promise, is an
AsyncStore.
Required Methods§
Sourcefn write_file(&self, name: &str, bytes: &[u8]) -> Result<()>
fn write_file(&self, name: &str, bytes: &[u8]) -> Result<()>
Replaces the file name with bytes, atomically: a reader sees the
old content or the new.
Sourcefn append_file(&self, name: &str, bytes: &[u8]) -> Result<()>
fn append_file(&self, name: &str, bytes: &[u8]) -> Result<()>
Adds bytes at the end of the file name, which it creates when
there is none.
Sourcefn read_file(&self, name: &str) -> Result<Vec<u8>>
fn read_file(&self, name: &str) -> Result<Vec<u8>>
The file name; io::ErrorKind::NotFound when there is none.
Sourcefn remove_file(&self, name: &str) -> Result<()>
fn remove_file(&self, name: &str) -> Result<()>
Removes the file name; removing one that is not there succeeds.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".