Skip to main content

HostStoreWithStore

Trait HostStoreWithStore 

pub trait HostStoreWithStore: HasData + Send {
    // Required methods
    fn open<T>(
        accessor: &Accessor<T, Self>,
        label: String,
    ) -> impl Future<Output = Result<Result<Resource<Store>, Error>, Error>> + Send
       where T: Send;
    fn get<T>(
        accessor: &Accessor<T, Self>,
        self_: Resource<Store>,
        key: String,
    ) -> impl Future<Output = Result<Result<Option<Vec<u8>>, Error>, Error>> + Send
       where T: Send;
    fn set<T>(
        accessor: &Accessor<T, Self>,
        self_: Resource<Store>,
        key: String,
        value: Vec<u8>,
    ) -> impl Future<Output = Result<Result<(), Error>, Error>> + Send
       where T: Send;
    fn delete<T>(
        accessor: &Accessor<T, Self>,
        self_: Resource<Store>,
        key: String,
    ) -> impl Future<Output = Result<Result<(), Error>, Error>> + Send
       where T: Send;
    fn exists<T>(
        accessor: &Accessor<T, Self>,
        self_: Resource<Store>,
        key: String,
    ) -> impl Future<Output = Result<Result<bool, Error>, Error>> + Send
       where T: Send;
    fn get_keys<T>(
        accessor: &Accessor<T, Self>,
        self_: Resource<Store>,
    ) -> impl Future<Output = Result<(StreamReader<String>, FutureReader<Result<(), Error>>), Error>> + Send
       where T: Send;
}

Required Methods§

fn open<T>( accessor: &Accessor<T, Self>, label: String, ) -> impl Future<Output = Result<Result<Resource<Store>, Error>, Error>> + Send
where T: 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.

fn get<T>( accessor: &Accessor<T, Self>, self_: Resource<Store>, key: String, ) -> impl Future<Output = Result<Result<Option<Vec<u8>>, Error>, Error>> + Send
where T: Send,

Get the value associated with the specified key

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

fn set<T>( accessor: &Accessor<T, Self>, self_: Resource<Store>, key: String, value: Vec<u8>, ) -> impl Future<Output = Result<Result<(), Error>, Error>> + Send
where T: Send,

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

fn delete<T>( accessor: &Accessor<T, Self>, self_: Resource<Store>, key: String, ) -> impl Future<Output = Result<Result<(), Error>, Error>> + Send
where T: Send,

Delete the tuple with the specified key

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

fn exists<T>( accessor: &Accessor<T, Self>, self_: Resource<Store>, key: String, ) -> impl Future<Output = Result<Result<bool, Error>, Error>> + Send
where T: Send,

Return whether a tuple exists for the specified key

fn get_keys<T>( accessor: &Accessor<T, Self>, self_: Resource<Store>, ) -> impl Future<Output = Result<(StreamReader<String>, FutureReader<Result<(), Error>>), Error>> + Send
where T: Send,

Return a list of all the keys

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.

Implementors§