Imp

Struct Imp 

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

Cwtch bot

Implementations§

Source§

impl Imp

Source

pub fn spawn(behaviour: Behaviour, password: String, home_dir: String) -> Self

Create a new imp bot with the specified behaviour start_cwtch is called on it

Examples found in repository?
examples/echobot.rs (line 22)
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 behaviour_mut(&self) -> &Behaviour

Source

pub fn behaviour_allowlist_add(&mut self, contact: ContactIdentity)

Source

pub fn behaviour_allowlist_rm(&mut self, contact: ContactIdentity)

Source

pub fn event_loop<T>(&mut self, handler: &mut T)
where T: EventHandler,

The main event loop handler for the bot, supply your own customer handler to handle events after the imp’s automatic handling has processed the event

Examples found in repository?
examples/echobot.rs (line 23)
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}

Auto Trait Implementations§

§

impl Freeze for Imp

§

impl !RefUnwindSafe for Imp

§

impl !Send for Imp

§

impl !Sync for Imp

§

impl Unpin for Imp

§

impl !UnwindSafe for Imp

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.