Trait HostStore

Source
pub trait HostStore: Sized + Send {
    // Required methods
    fn open(
        &mut self,
        label: String,
    ) -> impl Future<Output = Result<Result<Resource<Store>, Error>>> + Send;
    fn get(
        &mut self,
        self_: Resource<Store>,
        key: String,
    ) -> impl Future<Output = Result<Result<Option<Vec<u8>>, Error>>> + Send;
    fn set(
        &mut self,
        self_: Resource<Store>,
        key: String,
        value: Vec<u8>,
    ) -> impl Future<Output = Result<Result<(), Error>>> + Send;
    fn delete(
        &mut self,
        self_: Resource<Store>,
        key: String,
    ) -> impl Future<Output = Result<Result<(), Error>>> + Send;
    fn exists(
        &mut self,
        self_: Resource<Store>,
        key: String,
    ) -> impl Future<Output = Result<Result<bool, Error>>> + Send;
    fn get_keys(
        &mut self,
        self_: Resource<Store>,
    ) -> impl Future<Output = Result<Result<Vec<String>, Error>>> + Send;
    fn drop(
        &mut self,
        rep: Resource<Store>,
    ) -> impl Future<Output = Result<()>> + Send;
}

Required Methods§

Source

fn open( &mut self, label: String, ) -> impl Future<Output = Result<Result<Resource<Store>, Error>>> + Send

Open the store with the specified label.

label must refer to a store allowed in the spin.toml manifest.

error::no-such-store will be raised if the label is not recognized.

Source

fn get( &mut self, self_: Resource<Store>, key: String, ) -> impl Future<Output = Result<Result<Option<Vec<u8>>, Error>>> + Send

Get the value associated with the specified key

Returns ok(none) if the key does not exist.

Source

fn set( &mut self, self_: Resource<Store>, key: String, value: Vec<u8>, ) -> impl Future<Output = Result<Result<(), Error>>> + Send

Set the value associated with the specified key overwriting any existing value.

Source

fn delete( &mut self, self_: Resource<Store>, key: String, ) -> impl Future<Output = Result<Result<(), Error>>> + Send

Delete the tuple with the specified key

No error is raised if a tuple did not previously exist for key.

Source

fn exists( &mut self, self_: Resource<Store>, key: String, ) -> impl Future<Output = Result<Result<bool, Error>>> + Send

Return whether a tuple exists for the specified key

Source

fn get_keys( &mut self, self_: Resource<Store>, ) -> impl Future<Output = Result<Result<Vec<String>, Error>>> + Send

Return a list of all the keys

Source

fn drop( &mut self, rep: Resource<Store>, ) -> impl Future<Output = Result<()>> + Send

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<_T: HostStore + ?Sized + Send> HostStore for &mut _T

Source§

async fn open( &mut self, label: String, ) -> Result<Result<Resource<Store>, Error>>

Open the store with the specified label.

label must refer to a store allowed in the spin.toml manifest.

error::no-such-store will be raised if the label is not recognized.

Source§

async fn get( &mut self, self_: Resource<Store>, key: String, ) -> Result<Result<Option<Vec<u8>>, Error>>

Get the value associated with the specified key

Returns ok(none) if the key does not exist.

Source§

async fn set( &mut self, self_: Resource<Store>, key: String, value: Vec<u8>, ) -> Result<Result<(), Error>>

Set the value associated with the specified key overwriting any existing value.

Source§

async fn delete( &mut self, self_: Resource<Store>, key: String, ) -> Result<Result<(), Error>>

Delete the tuple with the specified key

No error is raised if a tuple did not previously exist for key.

Source§

async fn exists( &mut self, self_: Resource<Store>, key: String, ) -> Result<Result<bool, Error>>

Return whether a tuple exists for the specified key

Source§

async fn get_keys( &mut self, self_: Resource<Store>, ) -> Result<Result<Vec<String>, Error>>

Return a list of all the keys

Source§

async fn drop(&mut self, rep: Resource<Store>) -> Result<()>

Implementors§