Struct fastly_kv_preview::object_store::ObjectStore
source · [−]pub struct ObjectStore { /* private fields */ }
Expand description
A key-value store backed by central cloud storage.
Keys in the Object Store must follow the GCS Object naming guidelines.
Implementations
sourceimpl ObjectStore
impl ObjectStore
sourcepub fn open(name: &str) -> Result<Option<Self>, StoreError>
pub fn open(name: &str) -> Result<Option<Self>, StoreError>
Open the Object Store with the given name.
If there is no store by that name, this returns Ok(None)
.
If the Object Store feature is not enabled for the current service, this function returns an error.
sourcepub fn lookup(&self, key: &str) -> Result<Option<Body>, StoreError>
pub fn lookup(&self, key: &str) -> Result<Option<Body>, StoreError>
Look up a value in the Object Store.
Returns Ok(Some(Body))
if the value is found, and Ok(None)
if the key was not found or
is expired.
sourcepub fn lookup_bytes(&self, key: &str) -> Result<Option<Vec<u8>>, StoreError>
pub fn lookup_bytes(&self, key: &str) -> Result<Option<Vec<u8>>, StoreError>
Look up a value in the Object 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
or is expired.
sourcepub fn lookup_str(&self, key: &str) -> Result<Option<String>, StoreError>
pub fn lookup_str(&self, key: &str) -> Result<Option<String>, StoreError>
Look up a value in the Object 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 or
is expired.
Panics
Panics if the value is not a valid UTF-8 string.
sourcepub fn insert(
&mut self,
key: &str,
value: impl Into<Body>
) -> Result<(), StoreError>
pub fn insert(
&mut self,
key: &str,
value: impl Into<Body>
) -> Result<(), StoreError>
Insert a value into the Object 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.
Auto Trait Implementations
impl RefUnwindSafe for ObjectStore
impl Send for ObjectStore
impl Sync for ObjectStore
impl Unpin for ObjectStore
impl UnwindSafe for ObjectStore
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more