pub struct MessageManager<S>where
    S: Write + Read,
{ /* private fields */ }
Expand description

Static structure that is responsible for (de)serializing and sending/receiving Cast protocol messages.

Implementations§

Sends message to the Cast Device.

Arguments
  • message - CastMessage instance to be sent to the Cast Device.

Waits for the next CastMessage available. Can also return existing message from the internal message buffer containing messages that have been received previously, but haven’t been consumed for some reason (e.g. during receive_find_map call).

Return value

Result containing parsed CastMessage or Error.

Waits for the next CastMessage for which f returns valid mapped value. Messages in which f is not interested are placed into internal message buffer and can be later retrieved with receive. This method always reads from the stream.

Example
message_manager.receive_find_map(|message| {
  if !can_handle(message) {
    return Ok(None);
  }

  parse(message);

  Ok(Some(()))
})?;
Arguments
  • f - Function that analyzes and maps CastMessage to any other type. If message doesn’t look like something f is looking for, then Ok(None) should be returned so that message is not lost and placed into internal message buffer for later retrieval.
Return value

Result containing parsed CastMessage or Error.

Generates unique integer number that is used in some requests to map them with the response.

Return value

Unique (in the scope of this particular MessageManager instance) integer number.

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.