Struct stun::agent::Agent[][src]

pub struct Agent { /* fields omitted */ }
Expand description

Agent is low-level abstraction over transaction list that handles concurrency (all calls are goroutine-safe) and time outs (via Collect call).

Implementations

new initializes and returns new Agent with provided handler.

stop_with_error removes transaction from list and calls handler with provided error. Can return ErrTransactionNotExists and ErrAgentClosed.

process incoming message, synchronously passing it to handler.

close terminates all transactions with ErrAgentClosed and renders Agent to closed state.

start registers transaction with provided id and deadline. Could return ErrAgentClosed, ErrTransactionExists.

Agent handler is guaranteed to be eventually called.

stop stops transaction by id with ErrTransactionStopped, blocking until handler returns.

collect terminates all transactions that have deadline before provided time, blocking until all handlers will process ErrTransactionTimeOut. Will return ErrAgentClosed if agent is already closed.

It is safe to call Collect concurrently but makes no sense.

set_handler sets agent handler to h.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.