pub struct SignalBuilder { /* private fields */ }Implementations§
Source§impl SignalBuilder
impl SignalBuilder
pub fn validate(self) -> Result<Self>
Sourcepub fn build(self) -> Result<Signal>
pub fn build(self) -> Result<Signal>
Builds and validates the Signal.
Consumes the builder and returns a fully constructed and validated Signal.
§Errors
Returns an error if:
- Any required field is missing (name, start_bit, length, byte_order, unsigned, factor, offset, min, max)
- Name exceeds maximum length (32 characters)
- Signal length is invalid (zero or exceeds 64 bits)
- Min value exceeds max value
- Receivers fail to build
§Examples
use dbc_rs::{SignalBuilder, ByteOrder, ReceiversBuilder};
let signal = SignalBuilder::new()
.name("EngineSpeed")
.start_bit(0)
.length(16)
.byte_order(ByteOrder::LittleEndian)
.unsigned(true)
.factor(0.25)
.offset(0.0)
.min(0.0)
.max(8000.0)
.unit("rpm")
.receivers(ReceiversBuilder::new().add_node("TCM"))
.build()?;
assert_eq!(signal.name(), "EngineSpeed");
assert_eq!(signal.factor(), 0.25);Source§impl SignalBuilder
impl SignalBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new SignalBuilder with no fields set.
§Examples
use dbc_rs::SignalBuilder;
let builder = SignalBuilder::new();
// Must set name, start_bit, length, and byte_order before buildingSourcepub fn unit(self, unit: impl AsRef<str>) -> Self
pub fn unit(self, unit: impl AsRef<str>) -> Self
Sets the unit of measurement for this signal (e.g., “km/h”, “rpm”, “°C”).
Sourcepub fn start_bit(self, start_bit: u16) -> Self
pub fn start_bit(self, start_bit: u16) -> Self
Sets the start bit position of the signal in the CAN message payload.
Sourcepub fn byte_order(self, byte_order: ByteOrder) -> Self
pub fn byte_order(self, byte_order: ByteOrder) -> Self
Sets the byte order (endianness) of the signal.
Sourcepub fn unsigned(self, unsigned: bool) -> Self
pub fn unsigned(self, unsigned: bool) -> Self
Sets whether the signal is unsigned (true) or signed (false).
Sourcepub fn factor(self, factor: f64) -> Self
pub fn factor(self, factor: f64) -> Self
Sets the scaling factor for converting raw values to physical values (physical = raw * factor + offset).
Sourcepub fn offset(self, offset: f64) -> Self
pub fn offset(self, offset: f64) -> Self
Sets the offset for converting raw values to physical values (physical = raw * factor + offset).
Sourcepub fn receivers(self, receivers: ReceiversBuilder) -> Self
pub fn receivers(self, receivers: ReceiversBuilder) -> Self
Sets the receivers (ECU nodes) that subscribe to this signal.
§Arguments
receivers- AReceiversBuilderspecifying which nodes receive this signal
§Examples
use dbc_rs::{SignalBuilder, ReceiversBuilder};
let receivers = ReceiversBuilder::new()
.add_node("ECU1")
.add_node("ECU2");
let builder = SignalBuilder::new()
.receivers(receivers);Trait Implementations§
Source§impl Clone for SignalBuilder
impl Clone for SignalBuilder
Source§fn clone(&self) -> SignalBuilder
fn clone(&self) -> SignalBuilder
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SignalBuilder
impl Debug for SignalBuilder
Auto Trait Implementations§
impl Freeze for SignalBuilder
impl RefUnwindSafe for SignalBuilder
impl Send for SignalBuilder
impl Sync for SignalBuilder
impl Unpin for SignalBuilder
impl UnwindSafe for SignalBuilder
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)