pub struct FilesBackend { /* private fields */ }Expand description
Content stored one file per address in a Location, through
tilo-files’ synchronous operations (in a page, the profile’s mirror of
its app files, written through to the origin-private file system).
Implementations§
Source§impl FilesBackend
impl FilesBackend
pub fn new(location: Location, limits: ContentLimits) -> Self
pub fn limits(&self) -> ContentLimits
Trait Implementations§
Source§impl ContentBackend for FilesBackend
impl ContentBackend for FilesBackend
Source§fn put(
&self,
reader: &mut dyn Read,
_mime: &str,
) -> Result<Stored, ContentError>
fn put( &self, reader: &mut dyn Read, _mime: &str, ) -> Result<Stored, ContentError>
Store everything
reader yields, returning its address. Storing content already present
is a no-op that succeeds. mime is advisory (a backend may index or serve by it). Read morefn open(&self, hash: &str) -> Result<Option<ContentReader>, ContentError>
fn has(&self, hash: &str) -> bool
Source§fn collect_unreferenced(
&self,
live: &BTreeSet<String>,
) -> Result<Collected, ContentError>
fn collect_unreferenced( &self, live: &BTreeSet<String>, ) -> Result<Collected, ContentError>
Remove every item whose address is not in
live, which must be complete: the caller
asserts nothing outside it is referenced by anything it is responsible for. Read moreSource§fn max_item_bytes(&self) -> usize
fn max_item_bytes(&self) -> usize
The largest item this store accepts: a write that hashes before it seals refuses a larger
one as it reads it, rather than holding it whole first (
ContentStore::put_reader).Source§fn put_many(&self, items: &[(&[u8], &str)]) -> Vec<Result<Stored, ContentError>>
fn put_many(&self, items: &[(&[u8], &str)]) -> Vec<Result<Stored, ContentError>>
Store many items, answering each address in order: what
Self::put
does for each, done together where a backend can (one index update, one
flush), so a folder of small files costs its bytes rather than its
calls. A failing item leaves the others’ answers in place.Source§fn open_at(
&self,
hash: &str,
offset: u64,
) -> Result<Option<ContentReader>, ContentError>
fn open_at( &self, hash: &str, offset: u64, ) -> Result<Option<ContentReader>, ContentError>
The content at
hash read from offset on: a backend that keeps it in a file seeks
there, so serving one piece of a large item reads only that piece. Bytes read so are not
checked against the address (that takes the whole item); sealed content is still
checked chunk by chunk as it opens. Read moreSource§fn size(&self, hash: &str) -> Option<u64>
fn size(&self, hash: &str) -> Option<u64>
The length of the content at
hash, when the store knows it without
reading the bytes: what a reader serving one piece of a large file
asks before it seeks there.Source§fn state(&self, hash: &str) -> ContentState
fn state(&self, hash: &str) -> ContentState
Where the content at
hash has got to. A backend that can fetch from elsewhere reports
ContentState::Pending while it does, and may start fetching when asked.Source§fn release(&self, hash: &str) -> Result<Collected, ContentError>
fn release(&self, hash: &str) -> Result<Collected, ContentError>
Remove the item
hash, when the one who keeps it here knows nothing it is responsible
for references it any longer (a quota letting the oldest item go). Content kept for
another reason under the same address goes with it, so a caller sharing a store removes
only what it alone keeps. Read moreWhether content stored here reaches beyond this device’s own copy: the device content
store serves it to the app’s other devices and members. A document may then refer
to content by address alone; with a store that is not shared, a member would be left
holding an address nothing can resolve.
Source§fn workspace_scoped(&self) -> bool
fn workspace_scoped(&self) -> bool
Whether this store answers only for content readable in one workspace: the device content
store reads through the scope the launcher handed the window, and serves an address only
when that workspace references it. A caller’s content reference is resolved only in such
a store, so naming a hash never reaches content from elsewhere on this machine.
Source§fn content_secret(&self) -> Option<SymmetricKey>
fn content_secret(&self) -> Option<SymmetricKey>
The secret the members who read what this store keeps hold, when it is at hand: a
sealing store (
ContentStore::sealing) then seals each item under a key derived from
it and the item’s bytes, rather than a fresh one, so the same bytes stored twice are the
same ciphertext under the same reference, kept and carried once. Read moreSource§fn put_sealed(
&self,
reader: &mut dyn Read,
mime: &str,
) -> Option<Result<Stored, ContentError>>
fn put_sealed( &self, reader: &mut dyn Read, mime: &str, ) -> Option<Result<Stored, ContentError>>
Seal and keep what
reader yields, when the store behind this backend seals what it is
handed itself, under the members’ secret it holds and this backend does not (a session’s
store, whose device’s daemon holds the workspace’s keys): the sealed reference it answers
is what a sealing store hands back. None, reading nothing, when the backend keeps only
what is sealed before it reaches it.Source§fn scratch_dir(&self) -> Option<PathBuf>
fn scratch_dir(&self) -> Option<PathBuf>
A directory beside the content this store keeps, where a sealing write may keep the
plaintext it hashes in a file rather than in memory.
None for a store with no directory
of its own: one that keeps content on a host, or holds it in memory.Auto Trait Implementations§
impl Forget for FilesBackend
impl Freeze for FilesBackend
impl Move for FilesBackend
impl RefUnwindSafe for FilesBackend
impl Send for FilesBackend
impl Sync for FilesBackend
impl Unpin for FilesBackend
impl UnsafeUnpin for FilesBackend
impl UnwindSafe for FilesBackend
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