[][src]Struct roa_core::Bucket

pub struct Bucket(_);

A wrapper of HashMap<String, String>, method get return a Variable.

Example

use roa_core::{Bucket, Variable};
let mut bucket = Bucket::new();
assert!(bucket.get("id").is_none());
assert!(bucket.insert("id", "1").is_none());
assert_eq!(1, bucket.get("id").unwrap().parse().unwrap());
assert_eq!(1, bucket.insert("id", "2").unwrap().parse().unwrap());

Methods

impl Bucket[src]

pub fn new() -> Self[src]

Construct an empty Bucket.

pub fn insert<'a>(
    &mut self,
    name: &'a str,
    value: impl ToString
) -> Option<Variable<'a>>
[src]

Inserts a key-value pair into the bucket.

If the bucket did not have this key present, None is returned.

If the bucket did have this key present, the value is updated, and the old value is returned.

Example

use roa_core::{Bucket, Variable};
let mut bucket = Bucket::new();
assert!(bucket.insert("id", "1").is_none());
assert_eq!(1, bucket.insert("id", "2").unwrap().parse().unwrap());

pub fn get<'a>(&self, name: &'a str) -> Option<Variable<'a>>[src]

If the bucket did not have this key present, None is returned.

If the bucket did have this key present, the key-value pair will be returned as a Variable

Example

use roa_core::{Bucket, Variable};
let mut bucket = Bucket::new();
assert!(bucket.get("id").is_none());
bucket.insert("id", "1");
assert_eq!(1, bucket.get("id").unwrap().parse().unwrap());

Trait Implementations

impl Clone for Bucket[src]

impl Debug for Bucket[src]

impl Default for Bucket[src]

Auto Trait Implementations

impl RefUnwindSafe for Bucket

impl Send for Bucket

impl Sync for Bucket

impl Unpin for Bucket

impl UnwindSafe for Bucket

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, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.