autd3_rs/client/
config.rs1use std::num::{NonZeroU32, NonZeroUsize};
2
3use autd3_rs_core::CoreId;
4use autd3_rs_core::RtPriority;
5use autd3_rs_core::RtSchedulePolicy;
6
7use crate::error::{Error, PayloadError};
8use crate::protocol::MAX_INFLIGHT;
9
10pub const MAX_DEVICES: usize = 128;
11
12#[derive(Clone, Copy, Debug)]
13pub struct ClientConfig {
14 pub timeout_cycles: NonZeroU32,
15 pub max_inflight: NonZeroUsize,
16 pub max_resync_rounds: NonZeroU32,
17 pub low_latency: bool,
18 pub reset_resend_cycles: NonZeroU32,
19 pub rt_priority: Option<RtPriority>,
20 pub rt_policy: RtSchedulePolicy,
21 pub rt_affinity: Option<CoreId>,
22 pub validate_state: bool,
23 pub require_supported_firmware: bool,
24}
25
26impl Default for ClientConfig {
27 fn default() -> Self {
28 Self {
29 timeout_cycles: NonZeroU32::new(10).unwrap(),
30 max_inflight: NonZeroUsize::new(MAX_INFLIGHT).unwrap(),
31 max_resync_rounds: NonZeroU32::new(8).unwrap(),
32 low_latency: false,
33 reset_resend_cycles: NonZeroU32::new(2).unwrap(),
34 rt_priority: autd3_rs_core::default_rt_priority(),
35 rt_policy: RtSchedulePolicy::default(),
36 rt_affinity: None,
37 validate_state: true,
38 require_supported_firmware: false,
39 }
40 }
41}
42
43impl ClientConfig {
44 pub(super) fn validate(self) -> Result<Self, Error> {
45 if self.max_inflight.get() > MAX_INFLIGHT {
46 return Err(PayloadError::MaxInflightTooLarge { max: MAX_INFLIGHT }.into());
47 }
48 Ok(self)
49 }
50}