Struct kv_assets::KVAssets[][src]

pub struct KVAssets<'ah> { /* fields omitted */ }

Serves static assets out of Worker KV storage.

Implementations

impl<'ah> KVAssets<'ah>[src]

pub fn init(
    index: &'ah [u8],
    account_id: &str,
    namespace_id: &str,
    auth_token: &str
) -> Self
[src]

Initialize handler

  • index: binary serialized index (created by cf_assets)
  • account_id: cloudflare account id
  • namespace_id: cloudflare namespace (printed by cf_assets)
  • auth_token: cloudflare OAuth token

pub fn init_with(index: &'ah [u8], kv: KV) -> Self[src]

Initialize with exiting KV parameters

pub async fn get_asset(&self, key: &str) -> Result<Option<Bytes>, Error>[src]

all-in-one method to get the asset from KV

pub fn lookup_key(&self, path: &str) -> Result<Option<AssetMetadata>, Error>[src]

Finds the path in the map, returning the "key" This lookup should reliably and quickly determine whether asset is in KV, as it doesn't require querying KV yet. Removes leading / if present Returns Ok(None) if Not found

pub async fn get_kv_value(&self, key: &str) -> Result<Bytes, Error>[src]

Lookup asset in worker kV storage. If the key passed had been obtained from lookup_key, but the value was not found, then one of the following occurred:

  • the asset was deleted from KV
  • the value timed out via TTL
  • the index is out of date

pub async fn put_kv_value<T: Into<Body>>(
    &self,
    key: &str,
    val: T,
    expiration_ttl: Option<u64>
) -> Result<(), Error>
[src]

Store a value in KV. Optionally, set expiration TTL, number of seconds in future when content should be automatically deleted. TTL must be at least 60.

Auto Trait Implementations

impl<'ah> !RefUnwindSafe for KVAssets<'ah>[src]

impl<'ah> Send for KVAssets<'ah>[src]

impl<'ah> !Sync for KVAssets<'ah>[src]

impl<'ah> Unpin for KVAssets<'ah>[src]

impl<'ah> UnwindSafe for KVAssets<'ah>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,