Files
DomiStream/crates/domistream/src/http/applist.rs
T

31 lines
1.1 KiB
Rust

//! `GET /applist` (`docs/PROTOCOL.md` 1.3).
/// Maximum size of an applist body, in bytes.
pub const MAX_APPLIST_BYTES: usize = 1024 * 1024;
/// Maximum number of apps accepted in one list.
pub const MAX_APPS: usize = 4096;
/// Maximum length of an app title, in bytes.
pub const MAX_APP_TITLE_BYTES: usize = 512;
/// One app the host can launch.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct App {
/// `ID`: the value for `appid` in launch.
pub id: u32,
/// `AppTitle`, unescaped.
pub title: String,
/// `IsHdrSupported == 1`.
pub hdr_supported: bool,
}
/// Parses an applist body. Apps keep the host's order; duplicate ids are refused.
///
/// # Errors
/// [`crate::Error::TooLarge`] over [`MAX_APPLIST_BYTES`], [`MAX_APPS`] or [`MAX_APP_TITLE_BYTES`],
/// [`crate::Error::HostStatus`] for a non-200 answer, [`crate::Error::Malformed`] for an `App` without `ID` or
/// `AppTitle`. Phase A: always [`crate::Error::Unimplemented`].
pub fn parse_app_list(body: &[u8]) -> crate::Result<Vec<App>> {
let _ = body;
Err(crate::Error::Unimplemented)
}