pub struct ValueDescriptionsBuilder { /* private fields */ }Expand description
Builder for creating ValueDescriptions programmatically.
This builder allows you to construct value descriptions when building DBC files programmatically. It validates that entries are within limits and non-empty.
§Examples
use dbc_rs::ValueDescriptionsBuilder;
let value_descriptions = ValueDescriptionsBuilder::new()
.add_entry(0, "Park")
.add_entry(1, "Reverse")
.add_entry(2, "Neutral")
.add_entry(3, "Drive")
.build()?;
assert_eq!(value_descriptions.get(0), Some("Park"));
assert_eq!(value_descriptions.get(1), Some("Reverse"));§Validation
The builder validates:
- At least one entry is required (non-empty)
- Maximum of 64 value descriptions (MAX_VALUE_DESCRIPTIONS)
- Description names must not exceed MAX_NAME_SIZE
§Feature Requirements
This builder requires the std feature to be enabled.
Implementations§
Source§impl ValueDescriptionsBuilder
impl ValueDescriptionsBuilder
Sourcepub fn validate(self) -> Result<Self>
pub fn validate(self) -> Result<Self>
Validates the builder configuration without consuming it.
§Errors
Returns an error if:
- The entry list is empty
- The number of entries exceeds the maximum allowed
§Examples
use dbc_rs::ValueDescriptionsBuilder;
let builder = ValueDescriptionsBuilder::new()
.add_entry(0, "Off")
.add_entry(1, "On")
.validate()?;Sourcepub fn build(self) -> Result<ValueDescriptions>
pub fn build(self) -> Result<ValueDescriptions>
Builds the ValueDescriptions from the builder.
§Errors
Returns an error if:
- The entry list is empty
- The number of entries exceeds the maximum allowed
- Any description exceeds MAX_NAME_SIZE
§Examples
use dbc_rs::ValueDescriptionsBuilder;
let value_descriptions = ValueDescriptionsBuilder::new()
.add_entry(0, "Park")
.add_entry(1, "Drive")
.build()?;Trait Implementations§
Source§impl Clone for ValueDescriptionsBuilder
impl Clone for ValueDescriptionsBuilder
Source§fn clone(&self) -> ValueDescriptionsBuilder
fn clone(&self) -> ValueDescriptionsBuilder
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 ValueDescriptionsBuilder
impl Debug for ValueDescriptionsBuilder
Auto Trait Implementations§
impl Freeze for ValueDescriptionsBuilder
impl RefUnwindSafe for ValueDescriptionsBuilder
impl Send for ValueDescriptionsBuilder
impl Sync for ValueDescriptionsBuilder
impl Unpin for ValueDescriptionsBuilder
impl UnwindSafe for ValueDescriptionsBuilder
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)