Struct ContentStore
pub struct ContentStore { /* private fields */ }Expand description
An app’s handle to binary content: cheap to clone, passed to whatever needs it.
Implementations§
§impl ContentStore
impl ContentStore
pub fn new(backend: impl ContentBackend + 'static) -> ContentStore
pub fn new(backend: impl ContentBackend + 'static) -> ContentStore
A store over backend.
pub fn from_backend(backend: Arc<dyn ContentBackend>) -> ContentStore
pub fn from_backend(backend: Arc<dyn ContentBackend>) -> ContentStore
A store over a shared backend.
pub fn memory() -> ContentStore
pub fn memory() -> ContentStore
Content that lives and dies with this handle and its clones: tests, headless tools.
pub fn in_dir(root: impl Into<PathBuf>) -> ContentStore
pub fn in_dir(root: impl Into<PathBuf>) -> ContentStore
Content in the directory root, created on first write.
pub fn local_for_app() -> ContentStore
pub fn local_for_app() -> ContentStore
The store an app keeps on this machine when the launcher handed it no device content
store (tilo_content_device::for_app prefers that one): the session’s shared directory
when the host names one ([SHARED_STORE_ENV]), otherwise, where files have no native path
(a browser page), the profile’s app files ([FilesBackend]), otherwise tilo/content in
the user’s data directory. Content an earlier version kept in the cache directory
(tilo/blobs) still reads. With no usable directory at all, content is kept in memory.
pub fn put(&self, bytes: &[u8]) -> Result<String, ContentError>
pub fn put(&self, bytes: &[u8]) -> Result<String, ContentError>
Store bytes, returning their address. The media type is sniffed from the content.
§Errors
See [ContentBackend::put].
pub fn put_reader(
&self,
reader: &mut dyn Read,
mime: &str,
) -> Result<Stored, ContentError>
pub fn put_reader( &self, reader: &mut dyn Read, mime: &str, ) -> Result<Stored, ContentError>
Store everything reader yields without holding it in memory: the device store sends it
to the daemon one runtime_fs::blobs::MAX_PUT_CHUNK at a time.
§Errors
See [ContentBackend::put].
pub fn put_inputs(&self, inputs: &ContentInputs) -> Result<(), ContentError>
pub fn put_inputs(&self, inputs: &ContentInputs) -> Result<(), ContentError>
Store every input inputs collected (an import’s images, say).
§Errors
The first refusal; inputs stored before it stay stored.
pub fn read(&self, hash: &str) -> Option<Vec<u8>>
pub fn read(&self, hash: &str) -> Option<Vec<u8>>
The verified content at hash, or None when it is not here (or not intact).
pub fn open(&self, hash: &str) -> Option<Box<dyn Read + Send>>
pub fn open(&self, hash: &str) -> Option<Box<dyn Read + Send>>
A streaming, verifying read of the content at hash; see [ContentReader].
Whether content stored here reaches the app’s other devices and collaborators; see
[ContentBackend::shared].
pub fn workspace_scoped(&self) -> bool
pub fn workspace_scoped(&self) -> bool
Whether this store answers only for content readable in one workspace;
see [ContentBackend::workspace_scoped].
pub fn for_one_workspace(self) -> ContentStore
pub fn for_one_workspace(self) -> ContentStore
This store, declared as one workspace’s (Self::workspace_scoped): for a host that
keeps a store for one workspace alone, so everything in it is that workspace’s (a
test’s profile, one workspace’s headless drive).
pub fn memory_in_workspace() -> ContentStore
pub fn memory_in_workspace() -> ContentStore
Content in memory, as one workspace’s store
(Self::for_one_workspace): for tests of what a
caller may name by reference.
pub fn collect_unreferenced(
&self,
live: &BTreeSet<String>,
) -> Result<Collected, ContentError>
pub fn collect_unreferenced( &self, live: &BTreeSet<String>, ) -> Result<Collected, ContentError>
Remove every item not named in live; see [ContentBackend::collect_unreferenced].
§Errors
See [ContentBackend::collect_unreferenced].
Trait Implementations§
§impl Clone for ContentStore
impl Clone for ContentStore
§fn clone(&self) -> ContentStore
fn clone(&self) -> ContentStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl ContentSource for ContentStore
impl ContentSource for ContentStore
Auto Trait Implementations§
impl Freeze for ContentStore
impl !RefUnwindSafe for ContentStore
impl Send for ContentStore
impl Sync for ContentStore
impl Unpin for ContentStore
impl UnsafeUnpin for ContentStore
impl !UnwindSafe for ContentStore
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more