[−][src]Struct twitchchat::Runner
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]
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]
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]
dispatcher: Dispatcher,
rate_limit: RateLimit
) -> (Runner, Control)
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]
&'_ mut self,
connector: Connector<IO>
) -> Result<Status, Error> where
IO: AsyncRead + AsyncWrite,
IO: Unpin + Send + Sync + 'static,
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
PING
s the connection when aPONG
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..
- An error if one was encountered while in operation
Ok(Status::Eof)
if it ran to completionOk(Status::Canceled)
if the associatedControl::stop
was called
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]
&'_ 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,
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 fromResult<Status, Error>
to a future of aResult<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 withOk(Status::Eof)
Err(..)
will cause this to exit withErr(err)
Trait Implementations
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,