Struct ManagerBuilder

Source
pub struct ManagerBuilder { /* private fields */ }

Implementations§

Source§

impl ManagerBuilder

A builder for creating a Manager instance with various event callbacks.

§Example

use asterisk_manager::ManagerBuilder;
use asterisk_manager::ManagerOptions;

let options = ManagerOptions {
    port: 5038,
    host: "example.com".to_string(),
    username: "admin".to_string(),
    password: "password".to_string(),
    events: false,
};

let manager = ManagerBuilder::new(options)
    .on_event("event_name", Box::new(|value| {
        // handle event
    }))
    .on_all_events(Box::new(|value| {
        // handle all events
    }))
    .on_all_raw_events(Box::new(|value| {
        // handle all raw events
    }))
    .on_all_response_events(Box::new(|value| {
        // handle all response events
    }))
    .build();

§Methods

  • new(options: ManagerOptions) -> Self: Creates a new ManagerBuilder with the specified options.
  • on_event(mut self, event: &str, callback: Box<dyn Fn(Value) + Send + Sync>) -> Self: Registers a callback for a specific event.
  • on_all_events(mut self, callback: Box<dyn Fn(Value) + Send + Sync>) -> Self: Registers a callback for all events.
  • on_all_raw_events(mut self, callback: Box<dyn Fn(Value) + Send + Sync>) -> Self: Registers a callback for all raw events.
  • on_all_response_events(mut self, callback: Box<dyn Fn(Value) + Send + Sync>) -> Self: Registers a callback for all response events.
  • build(self) -> Manager: Consumes the builder and returns a Manager instance.
Source

pub fn new(options: ManagerOptions) -> Self

Creates a new instance of the ManagerBuilder. Initializes the builder with the specified options.

Source

pub fn on_event( self, event: &str, callback: Box<dyn Fn(Value) + Send + Sync>, ) -> Self

Registers a callback for a specific event.

Source

pub fn on_all_events(self, callback: Box<dyn Fn(Value) + Send + Sync>) -> Self

Registers a callback for all events.

Source

pub fn on_all_raw_events( self, callback: Box<dyn Fn(Value) + Send + Sync>, ) -> Self

Registers a callback for all raw events.

Source

pub fn on_all_response_events( self, callback: Box<dyn Fn(Value) + Send + Sync>, ) -> Self

Registers a callback for all response events by actions sended to AMI Asterisk.

Source

pub fn build(self) -> Manager

Consumes the builder and returns a Manager instance.

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.