Struct fastly::ConfigStore

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

A Compute Config Store.

Implementations§

source§

impl ConfigStore

source

pub fn open(name: &str) -> Self

Open a config store, given its name.

§Examples
let merriam = ConfigStore::open("merriam webster");
let oed = ConfigStore::open("oxford english config store");
source

pub fn try_open(name: &str) -> Result<Self, OpenError>

Try to open a config store, given its name.

§Examples
let merriam = ConfigStore::try_open("merriam webster").unwrap();
source

pub fn get(&self, key: &str) -> Option<String>

Lookup a value in this config store.

If successful, this function returns Some(_) if an entry was found, or None if no entry with the given key was found.

§Examples
assert_eq!(
     config_store.get("bread"),
     Some(String::from("a usually baked and leavened food")),
);
assert_eq!(
    config_store.get("freedom"),
    Some(String::from("the absence of necessity, coercion, or constraint")),
);

// Otherwise, `get` will return nothing.
assert!(config_store.get("zzzzz").is_none());
§Panics

This may panic for any of the reasons that ConfigStore::try_get would return an error.

source

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

Try to lookup a value in this Config Store.

If successful, this function returns Ok(Some(_)) if an entry was found, or Ok(None) if no entry with the given key was found. This function returns Err(_) if the lookup failed.

§Examples
assert_eq!(
     config_store.try_get("bread").unwrap(),
     Some(String::from("a usually baked and leavened food")),
);
assert_eq!(
    config_store.try_get("freedom").unwrap(),
    Some(String::from("the absence of necessity, coercion, or constraint")),
);

// Otherwise, `try_get` will return nothing.
assert!(config_store.try_get("zzzzz").unwrap().is_none());
source

pub fn contains(&self, key: &str) -> bool

Return true if the config_store contains an entry with the given key.

§Examples
assert!(config_store.contains("key"));
§Panics

This may panic for any of the reasons that ConfigStore::try_get would return an error.

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.