Skip to main content

MemoryBackend

Struct MemoryBackend 

Source
pub struct MemoryBackend { /* private fields */ }

Implementations§

Source§

impl MemoryBackend

Source

pub fn new(limits: ContentLimits) -> Self

Source

pub fn limits(&self) -> ContentLimits

Trait Implementations§

Source§

impl ContentBackend for MemoryBackend

Source§

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 more
Source§

fn open(&self, hash: &str) -> Result<Option<ContentReader>, ContentError>

Source§

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 more
Source§

fn has(&self, hash: &str) -> bool

Source§

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 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 more
Source§

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 more
Source§

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>>

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 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 shared(&self) -> bool

Whether 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

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>

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 more
Source§

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>

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.
Source§

impl Default for MemoryBackend

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more