Dictionary

Structin fastlyfastly 0.13.1since 0.8.6View source
Deprecated: renamed to ConfigStore
pub struct Dictionary { /* private fields */ }

A Compute Dictionary.

Methods

contains

deprecatedView source
Deprecated: use method on ConfigStore instead
fn contains(&self, key: &str) -> bool

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

Examples

assert!(dictionary.contains("key"));

Panics

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

Parameters

self: &Self
key: &str

Returns

bool

get

deprecatedView source
Deprecated: use method on ConfigStore instead
fn get(&self, key: &str) -> Option<String>

Lookup a value in this dictionary.

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

Examples

1
2
3
4
5
6
7
8
9
10
11
assert_eq!(
dictionary.get("bread"),
Some(String::from("a usually baked and leavened food")),
);
assert_eq!(
dictionary.get("freedom"),
Some(String::from("the absence of necessity, coercion, or constraint")),
);
// Otherwise, `get` will return nothing.
assert!(dictionary.get("zzzzz").is_none());

Panics

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

Parameters

self: &Self
key: &str

Returns

Option<String>

open

deprecatedView source
Deprecated: use method on ConfigStore instead
fn open(name: &str) -> Self

Open a dictionary, given its name.

Examples

let merriam = Dictionary::open("merriam webster");
let oed = Dictionary::open("oxford english dictionary");

Parameters

name: &str

Returns

Self

try_get

deprecatedView source
Deprecated: use method on ConfigStore instead
fn try_get(&self, key: &str) -> Result<Option<String>, LookupError>

Try to lookup a value in this dictionary.

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

1
2
3
4
5
6
7
8
9
10
11
12
assert_eq!(
dictionary.try_get("bread")?,
Some(String::from("a usually baked and leavened food")),
);
assert_eq!(
dictionary.try_get("freedom")?,
Some(String::from("the absence of necessity, coercion, or constraint")),
);
// Otherwise, `try_get` will return nothing.
assert!(dictionary.try_get("zzzzz")?.is_none());
Ok(()) }

Parameters

self: &Self
key: &str

Returns

try_open

deprecatedView source
Deprecated: use method on ConfigStore instead
fn try_open(name: &str) -> Result<Self, OpenError>

Try to open a dictionary, given its name.

Examples

let merriam = Dictionary::try_open("merriam webster")?;

Parameters

name: &str

Returns

Auto trait implementations

Blanket implementations