Skip to main content

HttpStore

Struct HttpStore 

Source
pub struct HttpStore { /* private fields */ }
Expand description

A passalong-server workspace.

Implementations§

Source§

impl HttpStore

Source

pub fn new( client: Arc<Client>, sealer: Option<Sealer>, clock: Arc<dyn Clock>, ) -> Self

The workspace behind client: sealed with sealer, or plaintext.

Source

pub fn in_partition( client: Arc<Client>, sealer: Option<Sealer>, clock: Arc<dyn Clock>, partition: Partition, ) -> Self

The workspace’s partition.

Source

pub fn client(&self) -> &Arc<Client> ⓘ

The client this store sends with.

Source

pub fn id_for(&self, meta: &ItemMeta) -> Result<ItemId, StoreError>

The id meta’s item gets in this store: its creation time, and this store’s content key for its SHA-256.

§Errors

StoreError::Corrupt when meta’s SHA-256 is not one.

Source

pub async fn import( &self, meta: &ItemMeta, content: BoxRead, ) -> Result<ItemMeta, StoreError>

Stores another store’s item, with its metadata and creation time, under the id HttpStore::id_for gives it, and returns its metadata here. An item already stored under that id is left as it is. In the staged partition this is a re-encryption’s copy.

§Errors

StoreError::Corrupt when the content does not match meta’s SHA-256 and size, and the server’s refusals.

Trait Implementations§

Source§

impl Debug for HttpStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Store for HttpStore

Source§

fn key_id(&self) -> Option<KeyId>

Id of the data key this store seals items with; None for a plaintext store.
Source§

fn content_key(&self, digest: &ContentDigest) -> ContentKey

The content key that identifies content with digest in this store: the plain ContentDigest::content_key, or a keyed one in an encrypted store. Use it to look for content already stored.
Source§

fn put<'life0, 'async_trait>( &'life0 self, item: NewItem, content: BoxRead, ) -> Pin<Box<dyn Future<Output = Result<PutOutcome, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stores content as a new item, streaming it without buffering the whole content. Identical content already in the store is not stored again: the existing item is returned with created: false.
Source§

fn list<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<ItemMeta>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lists every item, newest first.
Source§

fn list_after<'life0, 'life1, 'async_trait>( &'life0 self, after: Option<&'life1 ItemId>, ) -> Pin<Box<dyn Future<Output = Result<Vec<ItemMeta>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Items newer than after, newest first, or every item for None. Only those items’ metadata is read, so polling for new items stays cheap on a large store.
Source§

fn list_ids<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<ItemId>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Every item’s id, newest first, without reading any metadata. The default lists every item; backends override it with something cheaper.
Source§

fn get<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 ItemId, ) -> Pin<Box<dyn Future<Output = Result<(ItemMeta, BoxRead), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns an item’s metadata and a stream of its content.
Source§

fn get_meta<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 ItemId, ) -> Pin<Box<dyn Future<Output = Result<ItemMeta, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

An item’s metadata alone, without opening its content. The default calls Store::get and drops the content; backends override it with a single metadata read. Read more
Source§

fn exists<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 ItemId, ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Whether an item exists.
Source§

fn find_by_content_key<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 ContentKey, ) -> Pin<Box<dyn Future<Output = Result<Option<ItemMeta>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Finds the oldest item whose content has key.
Source§

fn resolve<'life0, 'life1, 'async_trait>( &'life0 self, input: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<ItemId, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Turns what a user typed into one item id. Input without - is a prefix of the content key (for example 2cf2); input with - is a prefix of the full id. Case and surrounding spaces are ignored, and at least 4 characters are required.
Source§

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 ItemId, ) -> Pin<Box<dyn Future<Output = Result<ItemMeta, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes an item and returns its metadata. The item disappears from listings in one step, even if removing its data then fails.
Source§

fn clean_staging<'life0, 'async_trait>( &'life0 self, older_than: Duration, ) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes staging directories that interrupted uploads and deletions left behind, when older than older_than, and returns how many were removed. Younger ones may belong to uploads in progress and stay.
Source§

fn probe_write<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<WriteProbe, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Checks that the store accepts writes without storing an item: a probe is written where listings and other devices never look, then removed. The default reports WriteProbe::NotSupported. Read more
Source§

fn newest_id<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<ItemId>, StoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

👎Deprecated since 0.1.3:

pull mode no longer uses it; use list_ids and take the first

The newest item’s id, or None for an empty store. The default lists every item; backends override it with something cheaper.

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<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