dbc_rs/signal/builder/
mod.rs

1use crate::{ByteOrder, ReceiversBuilder};
2
3/// Builder for creating CAN signals programmatically.
4///
5/// Use this builder to construct [`Signal`](crate::Signal) instances with validated
6/// properties. Required fields (name, start_bit, length) must be set before calling
7/// [`build()`](Self::build).
8///
9/// # Examples
10///
11/// ```rust,no_run
12/// use dbc_rs::{SignalBuilder, ByteOrder};
13///
14/// let signal = SignalBuilder::new()
15///     .name("EngineRPM")
16///     .start_bit(0)
17///     .length(16)
18///     .byte_order(ByteOrder::LittleEndian)
19///     .unsigned(true)
20///     .factor(0.25)
21///     .offset(0.0)
22///     .min(0.0)
23///     .max(8000.0)
24///     .unit("rpm")
25///     .build()?;
26/// # Ok::<(), dbc_rs::Error>(())
27/// ```
28#[derive(Debug, Clone)]
29pub struct SignalBuilder {
30    pub(crate) name: Option<String>,
31    pub(crate) start_bit: Option<u16>,
32    pub(crate) length: Option<u16>,
33    pub(crate) byte_order: Option<ByteOrder>,
34    pub(crate) unsigned: Option<bool>,
35    pub(crate) factor: Option<f64>,
36    pub(crate) offset: Option<f64>,
37    pub(crate) min: Option<f64>,
38    pub(crate) max: Option<f64>,
39    pub(crate) unit: Option<String>,
40    pub(crate) receivers: ReceiversBuilder,
41    pub(crate) comment: Option<String>,
42}
43
44mod build;
45mod impls;