Skip to content
File

Blob: firmware/crates/radio-webrtc/src/lib.rs

rust53 lines
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 
8mod audio;
9mod channels;
10mod connection;
11mod network;
12 
13pub use channels::{SendOutcome, Stream};
14pub use connection::{Certificate, Peer, PeerState};
15pub use str0m::crypto;
16pub use str0m::crypto::CryptoProvider;
17 
18/// Diagnostics never include SDP, credentials, certificates, or packet contents.
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub struct Error {
21 context: &'static str,
22 code: Option<i32>,
23}
24 
25impl 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 
40impl 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 
50impl std::error::Error for Error {}
51 
52type Result<T> = std::result::Result<T, Error>;