Struct rust_cast::CastDevice

source ·
pub struct CastDevice<'a> {
    pub connection: ConnectionChannel<'a, SslStream<TcpStream>>,
    pub heartbeat: HeartbeatChannel<'a, SslStream<TcpStream>>,
    pub media: MediaChannel<'a, SslStream<TcpStream>>,
    pub receiver: ReceiverChannel<'a, SslStream<TcpStream>>,
    /* private fields */
}
Expand description

Structure that manages connection to a cast device.

Fields§

§connection: ConnectionChannel<'a, SslStream<TcpStream>>

Channel that manages connection responses/requests.

§heartbeat: HeartbeatChannel<'a, SslStream<TcpStream>>

Channel that allows connection to stay alive (via ping-pong requests/responses).

§media: MediaChannel<'a, SslStream<TcpStream>>

Channel that manages various media stuff.

§receiver: ReceiverChannel<'a, SslStream<TcpStream>>

Channel that manages receiving platform (e.g. Chromecast).

Implementations§

Connects to the cast device using host name and port.

Examples
use rust_cast::CastDevice;

let device = CastDevice::connect("192.168.1.2", 8009)?;
Arguments
  • host - Cast device host name.
  • port - Cast device port number.
Errors

This method may fail if connection to Cast device can’t be established for some reason (e.g. wrong host name or port).

Return value

Instance of CastDevice that allows you to manage connection.

Connects to the cast device using host name and port without host verification. Use on your own risk!

Examples
use rust_cast::CastDevice;

let device = CastDevice::connect_without_host_verification("192.168.1.2", 8009)?;
Arguments
  • host - Cast device host name.
  • port - Cast device port number.
Errors

This method may fail if connection to Cast device can’t be established for some reason (e.g. wrong host name or port).

Return value

Instance of CastDevice that allows you to manage connection.

Waits for any message returned by cast device (e.g. Chromecast) and returns its parsed version.

Examples
use rust_cast::ChannelMessage;


match cast_device.receive() {
    Ok(ChannelMessage::Connection(res)) => log::debug!("Connection message: {:?}", res),
    Ok(ChannelMessage::Heartbeat(_)) => cast_device.heartbeat.pong()?,
    Ok(_) => {},
    Err(err) => log::error!("Error occurred while receiving message {}", err)
}
Errors

Usually fails if message returned by device can’t be parsed.

Returned values

Parsed channel message.

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.