Expand description
§oxicast
Async Google Cast (Chromecast) client for Rust, built on tokio.
Discover, connect to, and control Cast devices. Handles TLS, heartbeats, reconnection, and request-response correlation automatically.
§Quick Start
use oxicast::{CastClient, CastApp, MediaInfo};
use std::time::Duration;
// Connect by IP (discovery is optional)
let client = CastClient::connect("192.168.1.100", 8009).await?;
// Launch an app and play media
client.launch_app(&CastApp::DefaultMediaReceiver).await?;
client.load_media(
&MediaInfo::new("https://example.com/video.mp4", "video/mp4"),
true,
0.0,
).await?;
// Control playback
client.pause().await?;
client.seek(60.0).await?;
client.play().await?;§Architecture
Three background tokio tasks handle the Cast protocol:
- A reader task decodes inbound messages and dispatches them
- A writer task serializes outbound commands without blocking reads
- A heartbeat task sends PING and detects connection loss
Commands respond instantly — they never wait for the next heartbeat cycle.
§Consuming status updates
Two options — use whichever fits your architecture:
CastClient::next_event()— event stream in atokio::select!loop. Bounded channel; events are dropped (not blocked) if the buffer fills.CastClient::watch_media_status()/CastClient::watch_receiver_status()— always-fresh latest state viatokio::sync::watch. No draining needed.
§Feature flags
Re-exports§
pub use error::Error;pub use error::Result;pub use event::CastEvent;pub use types::Application;pub use types::CastApp;pub use types::DeviceInfo;pub use types::IdleReason;pub use types::Image;pub use types::MediaInfo;pub use types::MediaMetadata;pub use types::MediaStatus;pub use types::PlayerState;pub use types::QueueItem;pub use types::ReceiverStatus;pub use types::RepeatMode;pub use types::StreamType;pub use types::Volume;
Modules§
- discovery
- mDNS device discovery for Cast devices on the local network.
- error
- Error types for oxicast.
- event
- Events emitted by a Cast device connection.
- serve
- Built-in HTTP server for casting local files to Chromecast devices.
- types
- Shared types for Cast protocol communication.
Structs§
- Cast
Client - A connected Google Cast device client.