pub struct EventBuilder<'atree> { /* private fields */ }
Expand description
An Event
builder
During the builder creation, it will set all the attributes to undefined
. If some attributes
are not assigned, they will be left undefined
.
Implementations§
Source§impl<'atree> EventBuilder<'atree>
impl<'atree> EventBuilder<'atree>
Sourcepub fn build(self) -> Result<Event, EventError>
pub fn build(self) -> Result<Event, EventError>
Build the corresponding Event
.
By default, the non-assigned attributes will be undefined.
§Examples
use a_tree::{ATree, AttributeDefinition};
let definitions = [
AttributeDefinition::boolean("private"),
AttributeDefinition::integer("exchange_id"),
AttributeDefinition::string_list("deal_ids"),
];
let atree = ATree::<u64>::new(&definitions).unwrap();
let mut builder = atree.make_event();
builder.with_integer("exchange_id", 1).unwrap();
builder.with_boolean("private", false).unwrap();
// The returned `Event` will have its `deal_ids` attribute `undefined` since it was not set
// by the builder
let event = builder.build().unwrap();
Sourcepub fn with_boolean(
&mut self,
name: &str,
value: bool,
) -> Result<(), EventError>
pub fn with_boolean( &mut self, name: &str, value: bool, ) -> Result<(), EventError>
Set the specified boolean attribute.
The specified attribute must exist within the crate::ATree
and its type must be boolean.
Sourcepub fn with_integer(&mut self, name: &str, value: i64) -> Result<(), EventError>
pub fn with_integer(&mut self, name: &str, value: i64) -> Result<(), EventError>
Set the specified integer attribute.
The specified attribute must exist within the crate::ATree
and its type must be integer.
Sourcepub fn with_float(
&mut self,
name: &str,
number: i64,
scale: u32,
) -> Result<(), EventError>
pub fn with_float( &mut self, name: &str, number: i64, scale: u32, ) -> Result<(), EventError>
Set the specified float attribute.
The specified attribute must exist within the crate::ATree
and its type must be float.
Sourcepub fn with_string(&mut self, name: &str, value: &str) -> Result<(), EventError>
pub fn with_string(&mut self, name: &str, value: &str) -> Result<(), EventError>
Set the specified string attribute.
The specified attribute must exist within the crate::ATree
and its type must be string.
Sourcepub fn with_integer_list(
&mut self,
name: &str,
value: &[i64],
) -> Result<(), EventError>
pub fn with_integer_list( &mut self, name: &str, value: &[i64], ) -> Result<(), EventError>
Set the specified list of integers attribute.
The specified attribute must exist within the crate::ATree
and its type must be a list
of integers.
Sourcepub fn with_undefined(&mut self, name: &str) -> Result<(), EventError>
pub fn with_undefined(&mut self, name: &str) -> Result<(), EventError>
Set the specified attribute to undefined
.
The specified attribute must exist within the crate::ATree
.
Sourcepub fn with_string_list(
&mut self,
name: &str,
values: &[&str],
) -> Result<(), EventError>
pub fn with_string_list( &mut self, name: &str, values: &[&str], ) -> Result<(), EventError>
Set the specified string list attribute.
The specified attribute must exist within the crate::ATree
and its type must be a list
of strings.
Trait Implementations§
Auto Trait Implementations§
impl<'atree> Freeze for EventBuilder<'atree>
impl<'atree> RefUnwindSafe for EventBuilder<'atree>
impl<'atree> Send for EventBuilder<'atree>
impl<'atree> Sync for EventBuilder<'atree>
impl<'atree> Unpin for EventBuilder<'atree>
impl<'atree> UnwindSafe for EventBuilder<'atree>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more