#![deny(warnings)]
#![allow(dead_code)]
// [TSM.ID].[11031972] -- All Rights Reserved. Proprietary & Confidential.
pub mod nexus;
pub mod router;
pub mod entity;
pub mod stream;
pub mod af_xdp;
pub mod chronos;
pub mod orbital;
pub mod genesis;
pub mod moq;

pub use nexus::Nexus;
pub use router::Router;
pub use moq::MoqRelayer;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_dominant_speaker() {
        assert!(!Router::is_dominant_speaker(1, 30, false)); // not premium
        assert!(Router::is_dominant_speaker(1, 30, true)); // premium + low vol
        assert!(!Router::is_dominant_speaker(1, 80, true)); // premium but high vol
    }

    #[test]
    fn test_coolest_core_assignment() {
        let cores = vec![3, 1, 7];
        let assigned = Router::assign_stream_to_coolest_core(&cores);
        assert_eq!(assigned, 3); // first = coolest
        let empty: Vec<usize> = vec![];
        assert_eq!(Router::assign_stream_to_coolest_core(&empty), 0); // fallback
    }

    #[test]
    fn test_route_stream_svc_filter() {
        let r = Router::new(0);
        // SVC spatial_id = (0xF0 >> 4) & 0x07 = 7, bandwidth_score=3 < 7 -> DROP
        let packet = bytes::Bytes::from(vec![0xF0, 0x00, 0x01, 0x02]);
        r.route_stream(packet, &["user1".into()], 3); // should drop (no panic)
    }
}
