[][src]Struct twitchchat::Runner

pub struct Runner { /* fields omitted */ }

A type that drive the event loop to completion, and optionally retries on an return condition.

This type is used to 'drive' the dispatcher and internal read/write futures.

Implementations

impl Runner[src]

pub fn new(dispatcher: Dispatcher) -> (Runner, Control)[src]

This is supported on feature="tokio" only.

Create a Runner with the provided dispatcher with the default rate limiter

Returns

This returns the Runner and a Control type that'll let you interact with the Runner.

pub fn new_without_rate_limit(dispatcher: Dispatcher) -> (Runner, Control)[src]

This is supported on feature="tokio" only.

Create a Runner without a rate limiter.

Warning

This is not advisable and goes against the 'rules' of the API.

You should prefer to use Runner::new to use a default rate limiter

Or, Runner::new_with_rate_limit if you know your 'bot' status is higher than normal.

Returns

This returns the Runner and a Control type that'll let you interact with the Runner.

pub fn new_with_rate_limit(
    dispatcher: Dispatcher,
    rate_limit: RateLimit
) -> (Runner, Control)
[src]

This is supported on feature="tokio" only.

Crate a new Runner with the provided dispatcher and rate limiter

Returns

This returns the Runner and a Control type that'll let you interact with the Runner.

pub async fn run_to_completion<'_, IO>(
    &'_ mut self,
    connector: Connector<IO>
) -> Result<Status, Error> where
    IO: AsyncRead + AsyncWrite,
    IO: Unpin + Send + Sync + 'static, 
[src]

This is supported on feature="tokio" only.

Run to completion.

This takes a Connector which acts a factory for producing IO types.

This will only call the connector factory once. If you want to reconnect automatically, refer to Runner::run_with_retry. That function takes in a retry strategy for determining how to continue on disconnection.

The follow happens during the operation of this future

  • Connects using the provided Connector
  • Automatically PINGs the connection when a PONG is received
  • Checks for timeouts.
  • Reads from the IO type, parsing and dispatching messages
  • Reads from the writer and forwards it to the IO type
  • Listens for user cancellation from the Control::stop method.

Returns a future that resolves to..

pub async fn run_with_retry<'_, IO, F, R>(
    &'_ mut self,
    connector: Connector<IO>,
    retry_check: F
) -> Result<(), Error> where
    IO: AsyncRead + AsyncWrite,
    IO: Unpin + Send + Sync + 'static,
    F: Fn(Result<Status, Error>) -> R,
    R: Future<Output = Result<bool, Error>> + Send + Sync + 'static, 
[src]

This is supported on feature="tokio" only.

Run to completion and applies a retry functor to the result.

This takes in a:

  • Connector which acts a factory for producing IO types.
  • retry_check is a functor from Result<Status, Error> to a future of a Result<bool, Error>.

You can pause in the retry_check to cause the next connection attempt to be delayed.

retry_check return values:

  • Ok(true) will cause this to reconnect.
  • Ok(false) will cause this to exit with Ok(Status::Eof)
  • Err(..) will cause this to exit with Err(err)

Trait Implementations

impl Debug for Runner[src]

Auto Trait Implementations

impl !RefUnwindSafe for Runner

impl Send for Runner

impl Sync for Runner

impl Unpin for Runner

impl !UnwindSafe for Runner

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.