[][src]Struct fizyr_rpc::RequestTracker

pub struct RequestTracker<Body> { /* fields omitted */ }

Tracker that manages open requests.

You normally do not need to work with a request tracker directly. It is used by the different peer structs internally.

Implementations

impl<Body> RequestTracker<Body>[src]

pub fn new(command_tx: UnboundedSender<Command<Body>>) -> Self[src]

Create a new request tracker.

The command_tx channel is used for command messages. All messages on the channel should be sent to the remote peer by a task with the receiving end of the channel.

pub fn allocate_sent_request(
    &mut self,
    service_id: i32
) -> Result<SentRequest<Body>, NoFreeRequestIdFound>
[src]

Allocate a request ID and register a new sent request.

pub fn remove_sent_request(
    &mut self,
    request_id: u32
) -> Result<(), UnknownRequestId>
[src]

Remove a sent request from the tracker.

This should be called when a request is finished to make the ID available again. Note that sent requests are also removed internally when they receive a response, or when they would receive a message but the SentRequest was dropped.

pub fn register_received_request(
    &mut self,
    request_id: u32,
    service_id: i32,
    body: Body
) -> Result<ReceivedRequest<Body>, DuplicateRequestId>
[src]

Register a new sent request.

Returns an error if the request ID is already in use.

pub fn remove_received_request(
    &mut self,
    request_id: u32
) -> Result<(), UnknownRequestId>
[src]

Remove a received request from the tracker.

This should be called when a request is finished to make the ID available again. Note that received requests are also removed internally when they would receive a message but the ReceivedRequest was dropped.

pub async fn process_incoming_message<'_>(
    &'_ mut self,
    message: Message<Body>
) -> Result<Option<Incoming<Body>>, ProcessIncomingMessageError>
[src]

Process an incoming message.

This will pass the message on to an open request if any matches.

Returns an error

  • if an incoming request message uses an already claimed request ID
  • if an incoming update or response message does not match an open request

Auto Trait Implementations

impl<Body> !RefUnwindSafe for RequestTracker<Body>

impl<Body> Send for RequestTracker<Body> where
    Body: Send

impl<Body> Sync for RequestTracker<Body> where
    Body: Send

impl<Body> Unpin for RequestTracker<Body>

impl<Body> !UnwindSafe for RequestTracker<Body>

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.