1use std::collections::HashMap;
2use std::net::SocketAddr;
3
4pub mod discovery;
5mod parse;
6mod serialize;
7
8pub use discovery::{DiscoveredCore, SoodDiscovery};
9pub use parse::parse;
10pub use serialize::serialize_query;
11
12#[derive(Debug, Clone)]
13pub struct SoodMessage {
14 pub from: SocketAddr,
15 pub msg_type: SoodType,
16 pub props: HashMap<String, Option<String>>,
17}
18
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub enum SoodType {
21 Query,
22 Response,
23}
24
25#[derive(Debug, thiserror::Error)]
26pub enum SoodError {
27 #[error("buffer too short: need at least 6 bytes, got {0}")]
28 BufferTooShort(usize),
29 #[error("invalid magic bytes")]
30 InvalidMagic,
31 #[error("unsupported version: {0}")]
32 UnsupportedVersion(u8),
33 #[error("invalid message type: {0}")]
34 InvalidType(u8),
35 #[error("zero-length property name")]
36 ZeroLengthName,
37 #[error("truncated TLV: name length {name_len} exceeds remaining {remaining} bytes")]
38 TruncatedName { name_len: usize, remaining: usize },
39 #[error("truncated TLV: value length header exceeds remaining {remaining} bytes")]
40 TruncatedValueHeader { remaining: usize },
41 #[error("truncated TLV: value length {value_len} exceeds remaining {remaining} bytes")]
42 TruncatedValue { value_len: usize, remaining: usize },
43 #[error("invalid UTF-8 in property name")]
44 InvalidNameUtf8(#[from] std::string::FromUtf8Error),
45 #[error("invalid UTF-8 in property value")]
46 InvalidValueUtf8,
47 #[error("I/O error: {0}")]
48 Io(String),
49}
50
51pub const SOOD_PORT: u16 = 9003;
52pub const SOOD_MULTICAST_IP: &str = "239.255.90.90";
53pub const ROON_CORE_SERVICE_ID: &str = "00720724-5143-4a9b-abac-0e50cba674bb";