clasp_core/
lib.rs

1//! CLASP Core
2//!
3//! Core types, encoding, and protocol primitives for CLASP v2.
4//! Creative Low-Latency Application Streaming Protocol.
5//!
6//! This crate provides:
7//! - Protocol message types ([`Message`], [`SignalType`])
8//! - Binary frame encoding/decoding ([`Frame`], [`codec`])
9//! - Address parsing and wildcard matching ([`Address`])
10//! - State management primitives ([`ParamState`])
11//! - Timing utilities ([`Timestamp`])
12
13#![cfg_attr(not(feature = "std"), no_std)]
14
15#[cfg(feature = "alloc")]
16extern crate alloc;
17
18pub mod address;
19pub mod codec;
20pub mod error;
21pub mod frame;
22#[cfg(feature = "std")]
23pub mod p2p;
24#[cfg(feature = "std")]
25pub mod security;
26pub mod state;
27pub mod time;
28pub mod types;
29
30pub use address::Address;
31pub use codec::{decode, encode};
32pub use error::{Error, Result};
33pub use frame::Frame;
34#[cfg(feature = "std")]
35pub use p2p::{
36    extract_target_session, is_p2p_address, is_p2p_signal_address, signal_address, P2PAnnounce,
37    P2PConfig, P2PConnectionState, P2PSignal, RoutingMode, TurnServer, P2P_ANNOUNCE, P2P_NAMESPACE,
38    P2P_SIGNAL_PREFIX,
39};
40#[cfg(feature = "std")]
41pub use security::{
42    Action, CpskValidator, Scope, SecurityMode, TokenInfo, TokenValidator, ValidationResult,
43    ValidatorChain,
44};
45pub use state::ParamState;
46pub use time::Timestamp;
47pub use types::*;
48
49/// Protocol version
50pub const PROTOCOL_VERSION: u8 = 2;
51
52/// Magic byte for frame identification
53pub const MAGIC_BYTE: u8 = 0x53; // 'S' for Streaming
54
55/// Default WebSocket port
56pub const DEFAULT_WS_PORT: u16 = 7330;
57
58/// Default UDP discovery port
59pub const DEFAULT_DISCOVERY_PORT: u16 = 7331;
60
61/// WebSocket subprotocol identifier
62pub const WS_SUBPROTOCOL: &str = "clasp.v2";
63
64/// mDNS service type
65pub const MDNS_SERVICE_TYPE: &str = "_clasp._tcp.local.";