turn_client_proto/
lib.rs

1// Copyright (C) 2025 Matthew Waters <matthew@centricular.com>
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9//! # turn-client-proto
10//!
11//! `turn-client-proto` provides a sans-IO API for a TURN client communicating with a TURN server.
12//!
13//! Relevant standards:
14//! - [RFC5766]
15//!
16//! [RFC5766]: https://datatracker.ietf.org/doc/html/rfc5766
17
18#![deny(missing_debug_implementations)]
19#![deny(missing_docs)]
20
21pub use stun_proto as stun;
22pub use turn_types as types;
23mod client;
24
25pub use client::{
26    BindChannelError, CreatePermissionError, DelayedChannelSend, DelayedMessageOrChannelSend,
27    DelayedMessageSend, TurnClient, TurnEvent, TurnPollRet, TurnRecvRet,
28};
29
30#[cfg(test)]
31mod tests {
32    use tracing::subscriber::DefaultGuard;
33    use tracing_subscriber::layer::SubscriberExt;
34    use tracing_subscriber::Layer;
35
36    pub fn test_init_log() -> DefaultGuard {
37        turn_types::debug_init();
38        let level_filter = std::env::var("TURN_LOG")
39            .or(std::env::var("RUST_LOG"))
40            .ok()
41            .and_then(|var| var.parse::<tracing_subscriber::filter::Targets>().ok())
42            .unwrap_or(
43                tracing_subscriber::filter::Targets::new().with_default(tracing::Level::TRACE),
44            );
45        let registry = tracing_subscriber::registry().with(
46            tracing_subscriber::fmt::layer()
47                .with_file(true)
48                .with_line_number(true)
49                .with_level(true)
50                .with_target(false)
51                .with_test_writer()
52                .with_filter(level_filter),
53        );
54        tracing::subscriber::set_default(registry)
55    }
56}