ironrdp_server/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#![doc = include_str!("../README.md")]
#![doc(
    html_logo_url = "https://webdevolutions.blob.core.windows.net/images/projects/devolutions/logos/devolutions-icon-shadow.svg"
)]
#![allow(clippy::arithmetic_side_effects)] // TODO: should we enable this lint back?

pub use {tokio, tokio_rustls};

#[macro_use]
extern crate tracing;

mod builder;
mod capabilities;
mod clipboard;
mod display;
mod encoder;
mod handler;
#[cfg(feature = "helper")]
mod helper;
mod server;
mod sound;

pub use clipboard::*;
pub use display::*;
pub use handler::*;
#[cfg(feature = "helper")]
pub use helper::*;
pub use server::*;
pub use sound::*;

#[cfg(feature = "__bench")]
pub mod bench {
    pub mod encoder {
        pub mod rfx {
            pub use crate::encoder::rfx::bench::{rfx_enc, rfx_enc_tile};
        }
    }
}

#[macro_export]
macro_rules! time_warn {
    ($context:expr, $threshold_ms:expr, $op:expr) => {{
        #[cold]
        fn warn_log(context: &str, duration: u128) {
            use ::core::sync::atomic::AtomicUsize;

            static COUNT: AtomicUsize = AtomicUsize::new(0);
            let current_count = COUNT.fetch_add(1, ::core::sync::atomic::Ordering::Relaxed);
            if current_count < 50 || current_count % 100 == 0 {
                ::tracing::warn!("{context} took {duration} ms! (count: {current_count})");
            }
        }

        let start = std::time::Instant::now();
        let result = $op;
        let duration = start.elapsed().as_millis();
        if duration > $threshold_ms {
            warn_log($context, duration);
        }
        result
    }};
}