BehaviourBuilder

Struct BehaviourBuilder 

Source
pub struct BehaviourBuilder { /* private fields */ }
Expand description

intermediary struct for building a Behaviour using builder patern

Implementations§

Source§

impl BehaviourBuilder

Source

pub fn new() -> Self

Returns a new empty default off for features behaviour builder

Examples found in repository?
examples/echobot.rs (line 19)
18fn main() {
19    let behaviour: Behaviour = BehaviourBuilder::new().name(BOT_NAME.to_string()).new_contact_policy(NewContactPolicy::Accept).contact_interaction_policy(ContactInteractionPolicy::Accept).build();
20    let event_loop_handle = thread::spawn(move || {
21        let mut echobot = Echobot {};
22        let mut bot = Imp::spawn(behaviour, PASSWORD.to_string(), BOT_HOME.to_string());
23        bot.event_loop::<Echobot>(echobot.borrow_mut());
24    });
25    event_loop_handle.join().expect("Error running event loop");
26}
Source

pub fn build(self) -> Behaviour

Build the defined behaviours into a Behaviour struct

Examples found in repository?
examples/echobot.rs (line 19)
18fn main() {
19    let behaviour: Behaviour = BehaviourBuilder::new().name(BOT_NAME.to_string()).new_contact_policy(NewContactPolicy::Accept).contact_interaction_policy(ContactInteractionPolicy::Accept).build();
20    let event_loop_handle = thread::spawn(move || {
21        let mut echobot = Echobot {};
22        let mut bot = Imp::spawn(behaviour, PASSWORD.to_string(), BOT_HOME.to_string());
23        bot.event_loop::<Echobot>(echobot.borrow_mut());
24    });
25    event_loop_handle.join().expect("Error running event loop");
26}
Source

pub fn groups(self, val: bool) -> Self

Control if the Behaviour of the bot should include groups (enabling experiments and the group experiment)

Source

pub fn fileshare(self, val: bool) -> Self

Control if the Behaviour of the bot should include filesharing (enabling experiments and the filesharing experiment)

Source

pub fn profile_pic_path(self, val: String) -> Self

Set a profile pic for the bot and enable the filesharing experiment

Source

pub fn name(self, val: String) -> Self

Set a name for the behaviour

Examples found in repository?
examples/echobot.rs (line 19)
18fn main() {
19    let behaviour: Behaviour = BehaviourBuilder::new().name(BOT_NAME.to_string()).new_contact_policy(NewContactPolicy::Accept).contact_interaction_policy(ContactInteractionPolicy::Accept).build();
20    let event_loop_handle = thread::spawn(move || {
21        let mut echobot = Echobot {};
22        let mut bot = Imp::spawn(behaviour, PASSWORD.to_string(), BOT_HOME.to_string());
23        bot.event_loop::<Echobot>(echobot.borrow_mut());
24    });
25    event_loop_handle.join().expect("Error running event loop");
26}
Source

pub fn new_contact_policy(self, val: NewContactPolicy) -> Self

Set a new contact policy for the behaviour

Examples found in repository?
examples/echobot.rs (line 19)
18fn main() {
19    let behaviour: Behaviour = BehaviourBuilder::new().name(BOT_NAME.to_string()).new_contact_policy(NewContactPolicy::Accept).contact_interaction_policy(ContactInteractionPolicy::Accept).build();
20    let event_loop_handle = thread::spawn(move || {
21        let mut echobot = Echobot {};
22        let mut bot = Imp::spawn(behaviour, PASSWORD.to_string(), BOT_HOME.to_string());
23        bot.event_loop::<Echobot>(echobot.borrow_mut());
24    });
25    event_loop_handle.join().expect("Error running event loop");
26}
Source

pub fn contact_interaction_policy(self, val: ContactInteractionPolicy) -> Self

Examples found in repository?
examples/echobot.rs (line 19)
18fn main() {
19    let behaviour: Behaviour = BehaviourBuilder::new().name(BOT_NAME.to_string()).new_contact_policy(NewContactPolicy::Accept).contact_interaction_policy(ContactInteractionPolicy::Accept).build();
20    let event_loop_handle = thread::spawn(move || {
21        let mut echobot = Echobot {};
22        let mut bot = Imp::spawn(behaviour, PASSWORD.to_string(), BOT_HOME.to_string());
23        bot.event_loop::<Echobot>(echobot.borrow_mut());
24    });
25    event_loop_handle.join().expect("Error running event loop");
26}
Source

pub fn group_invite_policy(self, val: GroupInvitePolicy) -> Self

Source

pub fn group_interaction_policy(self, val: GroupInteractionPolicy) -> Self

Source

pub fn allow_list(self, val: AllowListMembers) -> Self

Auto Trait Implementations§

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