spin_sdk::key_value

Struct 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 Freeze for Store

§

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

Source§

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

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.