pub trait Storage {
Show 16 methods
// Required methods
fn name(&self) -> Name;
fn names(&self, at: &Entry) -> String;
fn residency(&self) -> Residency;
fn read<'a>(
&'a self,
at: &'a Entry,
) -> impl Future<Output = Result<Option<Vec<u8>>>> + 'a;
fn exists<'a>(
&'a self,
at: &'a Entry,
) -> impl Future<Output = Result<bool>> + 'a;
fn write<'a>(
&'a self,
at: &'a Entry,
bytes: &'a [u8],
) -> impl Future<Output = Result<()>> + 'a;
fn append<'a>(
&'a self,
at: &'a Entry,
bytes: &'a [u8],
) -> impl Future<Output = Result<()>> + 'a;
fn truncate<'a>(
&'a self,
at: &'a Entry,
len: u64,
) -> impl Future<Output = Result<()>> + 'a;
fn list<'a>(
&'a self,
dir: &'a Entry,
) -> impl Future<Output = Result<Vec<String>>> + 'a;
fn remove<'a>(
&'a self,
at: &'a Entry,
) -> impl Future<Output = Result<()>> + 'a;
fn create_dir<'a>(
&'a self,
dir: &'a Entry,
) -> impl Future<Output = Result<()>> + 'a;
fn rename<'a>(
&'a mut self,
to: &'a Name,
) -> impl Future<Output = Result<()>> + 'a;
fn discard(&self) -> impl Future<Output = Result<()>> + '_;
// Provided methods
fn disk_path(&self) -> Option<&Path> { ... }
fn claim(&self, now: WallTime) -> impl Future<Output = Result<Claim>> + '_ { ... }
fn release(&self) { ... }
}Expand description
Where one container’s bytes live.
Required Methods§
Sourcefn names(&self, at: &Entry) -> String
fn names(&self, at: &Entry) -> String
What a report calls at — a platform path where there is one. Not
a promise that anything is there.
fn residency(&self) -> Residency
Sourcefn read<'a>(
&'a self,
at: &'a Entry,
) -> impl Future<Output = Result<Option<Vec<u8>>>> + 'a
fn read<'a>( &'a self, at: &'a Entry, ) -> impl Future<Output = Result<Option<Vec<u8>>>> + 'a
The bytes at at, or None where nothing is — which is not the
same as a read that did not work.
Sourcefn exists<'a>(
&'a self,
at: &'a Entry,
) -> impl Future<Output = Result<bool>> + 'a
fn exists<'a>( &'a self, at: &'a Entry, ) -> impl Future<Output = Result<bool>> + 'a
Whether anything stands at at. Separate from Self::read
because a payload is filed under a content hash, so the answer is
all a write needs — and reading a megabyte to learn it is already
there is the one thing that would make every commit cost the
artwork on the page.
Sourcefn write<'a>(
&'a self,
at: &'a Entry,
bytes: &'a [u8],
) -> impl Future<Output = Result<()>> + 'a
fn write<'a>( &'a self, at: &'a Entry, bytes: &'a [u8], ) -> impl Future<Output = Result<()>> + 'a
Whole file or nothing: a reader caught mid-write sees the previous contents, never half of each.
Sourcefn append<'a>(
&'a self,
at: &'a Entry,
bytes: &'a [u8],
) -> impl Future<Output = Result<()>> + 'a
fn append<'a>( &'a self, at: &'a Entry, bytes: &'a [u8], ) -> impl Future<Output = Result<()>> + 'a
Add bytes to the end of at, durably before returning.
fn truncate<'a>( &'a self, at: &'a Entry, len: u64, ) -> impl Future<Output = Result<()>> + 'a
Sourcefn list<'a>(
&'a self,
dir: &'a Entry,
) -> impl Future<Output = Result<Vec<String>>> + 'a
fn list<'a>( &'a self, dir: &'a Entry, ) -> impl Future<Output = Result<Vec<String>>> + 'a
What dir holds, by name, in no particular order.
fn remove<'a>(&'a self, at: &'a Entry) -> impl Future<Output = Result<()>> + 'a
Sourcefn create_dir<'a>(
&'a self,
dir: &'a Entry,
) -> impl Future<Output = Result<()>> + 'a
fn create_dir<'a>( &'a self, dir: &'a Entry, ) -> impl Future<Output = Result<()>> + 'a
Make dir a place entries can be written.
Provided Methods§
Sourcefn disk_path(&self) -> Option<&Path>
fn disk_path(&self) -> Option<&Path>
Where these bytes sit on a filesystem, for a shell that can name
one. None for a storage that has no such thing.
Sourcefn claim(&self, now: WallTime) -> impl Future<Output = Result<Claim>> + '_
fn claim(&self, now: WallTime) -> impl Future<Output = Result<Claim>> + '_
Claim the right to write this container.
The default is the lock entry a container has always carried: a row naming the process that holds it, broken when that process is gone. A storage whose host keeps locks of its own answers from that instead — which is not a nicety in a browser, where nothing can be asked whether the tab that left an entry behind is still there.
Sourcefn release(&self)
fn release(&self)
Give the lock back.
Synchronous where the claim is not, because a container releases
its lock as it is dropped and a Drop cannot await. Which is why a
storage whose futures are not ready must hold its lock somewhere it
can let go of in one call — its host’s lock manager — rather than
in the entry the default writes: an entry it could not remove here
would outlive every session that took it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.