rusty_esp_video_esp/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]
2#![deny(unsafe_code)]
3//! `rusty_esp_video-esp` — chip backends for `rusty_esp_video`.
4//!
5//! This is the **wrap** crate of the package. Its first backend is the Track A
6//! stream server in [`net`]: plain `std::net` sockets and a minimal HTTP/1.1
7//! responder that serves the MJPEG multipart stream. ESP-IDF's `std` provides
8//! exactly these sockets on the chip, so the server that runs on a laptop
9//! today is the server the XIAO ESP32-S3 Sense runs in J1 — no port.
10//!
11//! `unsafe` is denied crate-wide; a backend that must use it at a DMA or FFI
12//! boundary opts in per block with `#[allow(unsafe_code)]` and a `// SAFETY:`
13//! comment stating the invariant.
14
15#[cfg(feature = "alloc")]
16extern crate alloc;
17
18#[cfg(all(feature = "esp-hal", feature = "esp-idf"))]
19compile_error!("enable exactly one track: `esp-hal` (no_std) or `esp-idf` (std)");
20
21pub use rusty_esp_video_core as core;
22
23#[cfg(feature = "std")]
24pub mod client;
25#[cfg(feature = "std")]
26pub mod net;
27#[cfg(feature = "std")]
28pub mod udp_net;
29
30/// Which track this build of the backend crate was compiled for.
31#[derive(Debug, Clone, Copy, PartialEq, Eq)]
32pub enum Track {
33 /// No chip backend compiled in: host build.
34 Host,
35 /// Track B — bare metal, esp-hal + Embassy.
36 EspHal,
37 /// Track A — std on ESP-IDF.
38 EspIdf,
39}
40
41/// The track this crate was built with.
42pub const TRACK: Track = if cfg!(feature = "esp-hal") {
43 Track::EspHal
44} else if cfg!(feature = "esp-idf") {
45 Track::EspIdf
46} else {
47 Track::Host
48};
49
50#[cfg(feature = "esp-hal")]
51pub mod hal {
52 //! Track B backends. embassy-net sockets land here with their esp-hal pin.
53}