Struct alfred::json::Builder
[−]
[src]
pub struct Builder<'a> { pub items: &'a [Item<'a>], pub variables: HashMap<&'a str, &'a str>, }
A helper type for writing out items with top-level variables.
Note: If you don't need top-level variables the write_items()
function is easier to use.
Fields
items: &'a [Item<'a>]
The items that will be written out.
variables: HashMap<&'a str, &'a str>
The variables that will be written out.
Methods
impl<'a> Builder<'a>
[src]
fn new() -> Builder<'a>
Returns a new Builder
with no items.
fn with_items(items: &'a [Item]) -> Builder<'a>
Returns a new Builder
with the given items.
fn write<W: Write>(self, w: W) -> Result<()>
Writes a complete JSON document representing the items and variables to the Write
.
The Write
is flushed after the JSON document is written.
fn items(self, items: &'a [Item]) -> Builder<'a>
Replaces the builder's items with items
.
fn variables(self, variables: HashMap<&'a str, &'a str>) -> Builder<'a>
Replaces the builder's variables with variables
.
fn variable(self, key: &'a str, value: &'a str) -> Builder<'a>
Inserts a new variable into the builder's variables.
fn set_items(&mut self, items: &'a [Item])
Replaces the builder's items with items
.
fn set_variables(&mut self, variables: HashMap<&'a str, &'a str>)
Replaces the builder's variables with variables
.
fn set_variable(&mut self, key: &'a str, value: &'a str)
Inserts a new variable into the builder's variables.
Trait Implementations
impl<'a> Clone for Builder<'a>
[src]
fn clone(&self) -> Builder<'a>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more