pub struct EmbeddedProvider<T> { /* private fields */ }
Expand description

An embedded database backend for storing and retrieving bindles and parcels.

Given a storage directory, EmbeddedProvider brings its own storage layout for keeping track of Bindles.

An EmbeddedProvider needs a search engine implementation. When invoices are created or yanked, the index will be updated.

Implementations§

source§

impl<T: Search + Send + Sync> EmbeddedProvider<T>

source

pub async fn new<P: AsRef<Path>>(storage_path: P, index: T) -> Result<Self>

Trait Implementations§

source§

impl<T: Clone> Clone for EmbeddedProvider<T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Search + Send + Sync> Provider for EmbeddedProvider<T>

source§

fn create_invoice<'life0, 'async_trait, I>( &'life0 self, invoice: I ) -> Pin<Box<dyn Future<Output = Result<(Invoice, Vec<Label>)>> + Send + 'async_trait>>where I: Signed + Verified + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

This takes an invoice and creates it in storage. Returns the newly created invoice and a list of missing parcels Read more
source§

fn get_yanked_invoice<'life0, 'async_trait, I>( &'life0 self, id: I ) -> Pin<Box<dyn Future<Output = Result<Invoice>> + Send + 'async_trait>>where I: TryInto<Id> + Send + 'async_trait, I::Error: Into<ProviderError>, Self: 'async_trait, 'life0: 'async_trait,

Load an invoice, even if it is yanked. This is called by the default implementation of get_invoice
source§

fn yank_invoice<'life0, 'async_trait, I>( &'life0 self, id: I ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where I: TryInto<Id> + Send + 'async_trait, I::Error: Into<ProviderError>, Self: 'async_trait, 'life0: 'async_trait,

Remove an invoice by ID
source§

fn create_parcel<'life0, 'life1, 'async_trait, I, R, B>( &'life0 self, bindle_id: I, parcel_id: &'life1 str, data: R ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where I: TryInto<Id> + Send + 'async_trait, I::Error: Into<ProviderError>, R: Stream<Item = Result<B>> + Unpin + Send + Sync + 'static + 'async_trait, B: Buf + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Creates a parcel with the associated sha. The parcel can be anything that implements Stream Read more
source§

fn get_parcel<'life0, 'life1, 'async_trait, I>( &'life0 self, bindle_id: I, parcel_id: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<Bytes>> + Unpin + Send + Sync>>> + Send + 'async_trait>>where I: TryInto<Id> + Send + 'async_trait, I::Error: Into<ProviderError>, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a specific parcel using its SHA. Read more
source§

fn parcel_exists<'life0, 'life1, 'async_trait, I>( &'life0 self, bindle_id: I, parcel_id: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where I: TryInto<Id> + Send + 'async_trait, I::Error: Into<ProviderError>, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Checks if the given parcel exists in storage. Read more
source§

fn get_invoice<'life0, 'async_trait, I>( &'life0 self, id: I ) -> Pin<Box<dyn Future<Output = Result<Invoice>> + Send + 'async_trait>>where I: TryInto<Id> + Send + 'async_trait, I::Error: Into<ProviderError>, Self: Sync + 'async_trait, 'life0: 'async_trait,

Load an invoice and return it Read more
source§

fn validate_parcel<'life0, 'life1, 'async_trait, I>( &'life0 self, bindle_id: I, parcel_id: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<Label>> + Send + 'async_trait>>where I: TryInto<Id> + Send + 'async_trait, I::Error: Into<ProviderError>, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Checks if the given parcel ID exists within an invoice. The default implementation will fetch the parcel and check if the given parcel ID exists. Returns the parcel label if valid. Most providers should implement some sort of caching for get_yanked_invoice to avoid fetching the invoice every single time a parcel is requested. Provider implementations may also implement this function to include other validation logic if desired.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for EmbeddedProvider<T>

§

impl<T> Send for EmbeddedProvider<T>where T: Send,

§

impl<T> Sync for EmbeddedProvider<T>where T: Sync,

§

impl<T> Unpin for EmbeddedProvider<T>where T: Unpin,

§

impl<T> !UnwindSafe for EmbeddedProvider<T>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · 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> 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 Twhere U: From<T>,

const: unstable · 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

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