Struct spin_sdk::key_value::Store

source ·
pub struct Store { /* private fields */ }
Expand description

An open key-value store

Implementations§

source§

impl Store

source

pub fn open_default() -> Result<Self, Error>

Open the default store.

This is equivalent to Store::open("default").

source§

impl Store

source

pub fn set_json<T: Serialize>( &self, key: impl AsRef<str>, value: &T ) -> Result<(), Error>

Serialize the given data to JSON, then set it as the value for the specified key.

source

pub fn get_json<T: DeserializeOwned>( &self, key: impl AsRef<str> ) -> Result<Option<T>, Error>

Deserialize an instance of type T from the value of key.

source§

impl Store

source

pub fn open(label: &str) -> Result<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§

impl Store

source

pub fn get(&self, key: &str) -> Result<Option<Vec<u8>>, Error>

Get the value associated with the specified key

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

source§

impl Store

source

pub fn set(&self, key: &str, value: &[u8]) -> Result<(), Error>

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

source§

impl Store

source

pub fn delete(&self, key: &str) -> Result<(), Error>

Delete the tuple with the specified key

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

source§

impl Store

source

pub fn exists(&self, key: &str) -> Result<bool, Error>

Return whether a tuple exists for the specified key

source§

impl Store

source

pub fn get_keys(&self) -> Result<Vec<String>, Error>

Return a list of all the keys

Trait Implementations§

source§

impl Debug for Store

source§

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

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

impl WasmResource for Store

source§

unsafe fn drop(handle: u32)

Invokes the [resource-drop]... intrinsic.

Auto Trait Implementations§

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnwindSafe for Store

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, 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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
source§

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

§

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.