Struct EventBuilder

Source
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>

Source

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();
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl<'atree> Debug for EventBuilder<'atree>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.