Engine

Struct Engine 

Source
pub struct Engine<I: AsyncRead + Unpin, O: AsyncWrite + Unpin> { /* private fields */ }
Expand description

The main connector to the Yate Telephone Engine.

Implementations§

Source§

impl Engine<AllowStdIo<Stdin>, AllowStdIo<Stdout>>

Source

pub fn stdio() -> Self

Initialize a connection to the engine via standard I/O.

Source§

impl<I: AsyncRead + Send + Unpin, O: AsyncWrite + Send + Unpin> Engine<I, O>

Source

pub fn from_io(rx: I, tx: O) -> Self

Initialize a connection to the engine with the provided I/O.

If the I/O is a socket or a TCP stream, the module must register itself with a Self::connect before doing anything.

Source

pub async fn install( &self, priority: impl Into<Option<u64>>, name: impl Into<String>, filter: impl Into<Option<(String, Option<String>)>>, ) -> Result<bool, Error>

Request the engine to install a message handler with the provided priority.

Source

pub async fn uninstall(&self, name: impl Into<String>) -> Result<bool, Error>

Request the engine to remove a previously installed handler.

Source

pub async fn watch(&self, name: impl Into<String>) -> Result<bool, Error>

Request the engine to install a message watcher.

Source

pub async fn unwatch(&self, name: impl Into<String>) -> Result<bool, Error>

Request the engine to remove a previously installed watcher.

Source

pub async fn setlocal( &self, name: impl Into<String>, value: impl Into<String>, ) -> Result<bool, Error>

Request the engine to set a local variable.

Source

pub async fn getlocal(&self, name: impl Into<String>) -> Result<String, Error>

Request the value of a local variable.

Source

pub async fn message( &self, name: impl Into<String>, retvalue: impl Into<String>, kv: BTreeMap<String, String>, ) -> Result<(bool, String, BTreeMap<String, String>), Error>

Send a Message to the telephony engine for processing.

Source

pub fn messages(&self) -> impl TryStream<Ok = Req, Error = Error>

Receive messages from the telephony engine for processing.

Source

pub async fn ack(&self, req: Req, processed: bool) -> Result<(), Error>

Acknowledge the message from the engine, letting it forward it to the next handler if !processed.

Source

pub async fn connect( &self, role: ConnectRole, channel: impl Into<Option<(String, Option<String>)>>, ) -> Result<(), Error>

Send a connect message to the engine for socket-based modules.

Source

pub async fn output(&self, text: impl Into<String>) -> Result<(), Error>

Output some arbitrary text to engine’s log, this is especially useful on socket-based modules.

Source

pub async fn debug( &self, level: DebugLevel, text: impl Into<String>, ) -> Result<(), Error>

Output some debug text to engine’s log, this is especially useful on socket-based modules.

Source

pub async fn quit(&self) -> Result<(), Error>

Tell the engine we desire to stop handling messages.

Auto Trait Implementations§

§

impl<I, O> !Freeze for Engine<I, O>

§

impl<I, O> !RefUnwindSafe for Engine<I, O>

§

impl<I, O> Send for Engine<I, O>
where O: Send, I: Send,

§

impl<I, O> Sync for Engine<I, O>
where O: Send, I: Send,

§

impl<I, O> Unpin for Engine<I, O>

§

impl<I, O> !UnwindSafe for Engine<I, O>

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more