Struct fastly::KVStore

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

A Compute KV Store.

Keys in the KV Store must follow the following rules:

  • Keys can contain any sequence of valid Unicode characters, of length 1-1024 bytes when UTF-8 encoded.
  • Keys cannot contain Carriage Return or Line Feed characters.
  • Keys cannot start with .well-known/acme-challenge/.
  • Keys cannot be named . or ...

Implementations§

source§

impl KVStore

source

pub fn open(name: &str) -> Result<Option<Self>, KVStoreError>

Open the KV Store with the given name.

If there is no store by that name, this returns Ok(None).

source

pub fn lookup(&self, key: &str) -> Result<Option<Body>, KVStoreError>

Look up a value in the KV Store.

Returns Ok(Some(Body)) if the value is found, and Ok(None) if the key was not found.

source

pub fn lookup_async( &self, key: &str ) -> Result<Option<PendingObjectStoreLookupHandle>, KVStoreError>

Initiate async lookup of a value in the KV Store.

Returns Ok(Some(PendingObjectStoreLookupHandle)) lookup creation is successful.

source

pub fn pending_lookup_wait( &self, pending_request_handle: PendingObjectStoreLookupHandle ) -> Result<Option<Body>, KVStoreError>

Look up a value in the KV Store.

Returns Ok(Some(Body)) if the value is found, and Ok(None) if the key was not found.

source

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

Look up a value in the KV Store, and return it as a byte vector.

Returns Ok(Some(Vec<u8>)) if the value is found, and Ok(None) if the key was not found.

source

pub fn lookup_str(&self, key: &str) -> Result<Option<String>, KVStoreError>

Look up a value in the KV Store, and return it as a string.

Returns Ok(Some(String)) if the value is found, and Ok(None) if the key was not found.

§Panics

Panics if the value is not a valid UTF-8 string.

source

pub fn insert( &mut self, key: &str, value: impl Into<Body> ) -> Result<(), KVStoreError>

Insert a value into the KV Store.

If the store already contained a value for this key, it will be overwritten.

The value may be provided as any type that can be converted to Body, such as &[u8], Vec<u8>, &str, or String.

§Value sizes

The size of the value must be known when calling this method. In practice, that means that if a Body value contains an external request or response, it must be encoded with Content-Length rather than Transfer-Encoding: chunked.

For the moment, this method will return StoreError::Unexpected(FastlyStatus::INVAL) if the value size is not known. This will be replaced by a more specific error value in a future release.

source

pub fn insert_async( &self, key: &str, value: impl Into<Body> ) -> Result<Option<PendingObjectStoreInsertHandle>, KVStoreError>

Initiate async insert of a value into the KV Store.

Returns Ok(Some(PendingObjectStoreInsertHandle)) if insert creation is successful.

source

pub fn pending_insert_wait( &self, pending_insert_handle: PendingObjectStoreInsertHandle ) -> Result<(), KVStoreError>

Insert a value in the KV Store.

Returns Ok(()) if the value is found, and KVStoreError if the key was not found.

source

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

Delete a value in the KV Store.

Returns Ok(()) if delete is successful.

source

pub fn delete_async( &self, key: &str ) -> Result<PendingObjectStoreDeleteHandle, KVStoreError>

Initiate async delete of a key the KV Store.

Returns Ok(PendingObjectStoreDeleteHandle) if delete creation is successful.

source

pub fn pending_delete_wait( &self, pending_delete_handle: PendingObjectStoreDeleteHandle ) -> Result<(), KVStoreError>

Delete a value in the KV Store.

Returns Ok(()) if the key is deleted, and KVStoreError if the key was not found.

Auto Trait Implementations§

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> Same for T

§

type Output = T

Should always be Self
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.