File
Blob: firmware/crates/radio-webrtc/src/lib.rs
| 1 | //! One-owner WebRTC transport with explicit channel IDs and bounded application queues. |
| 2 | //! |
| 3 | //! The caller supplies a connected interface address and a fresh certificate, |
| 4 | //! exchanges SDP through its signaling service, and polls regularly. No ESP-IDF, |
| 5 | //! HTTP, playback, or hardware dependencies live here. |
| 6 | #![forbid(unsafe_code)] |
| 7 | |
| 8 | mod audio; |
| 9 | mod channels; |
| 10 | mod connection; |
| 11 | mod network; |
| 12 | |
| 13 | pub use channels::{SendOutcome, Stream}; |
| 14 | pub use connection::{Certificate, Peer, PeerState}; |
| 15 | pub use str0m::crypto; |
| 16 | pub use str0m::crypto::CryptoProvider; |
| 17 | |
| 18 | /// Diagnostics never include SDP, credentials, certificates, or packet contents. |
| 19 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 20 | pub struct Error { |
| 21 | context: &'static str, |
| 22 | code: Option<i32>, |
| 23 | } |
| 24 | |
| 25 | impl Error { |
| 26 | fn new(context: &'static str) -> Self { |
| 27 | Self { |
| 28 | context, |
| 29 | code: None, |
| 30 | } |
| 31 | } |
| 32 | fn io(context: &'static str, error: std::io::Error) -> Self { |
| 33 | Self { |
| 34 | context, |
| 35 | code: error.raw_os_error(), |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | impl std::fmt::Display for Error { |
| 41 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 42 | f.write_str(self.context)?; |
| 43 | if let Some(code) = self.code { |
| 44 | write!(f, " (OS code {code})")?; |
| 45 | } |
| 46 | Ok(()) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | impl std::error::Error for Error {} |
| 51 | |
| 52 | type Result<T> = std::result::Result<T, Error>; |