Struct kv_assets::KVAssets [−][src]
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]
index: &'ah [u8],
account_id: &str,
namespace_id: &str,
auth_token: &str
) -> Self
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]
&self,
key: &str,
val: T,
expiration_ttl: Option<u64>
) -> Result<(), Error>
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,