Skip to main content

Config

Struct Config 

Source
#[non_exhaustive]
pub struct Config<'a> {
Show 13 fields pub dbc_name: &'a str, pub dbc_content: &'a str, pub debug_prints: bool, pub impl_debug: FeatureConfig<'a>, pub impl_defmt: FeatureConfig<'a>, pub impl_arbitrary: FeatureConfig<'a>, pub impl_serde: FeatureConfig<'a>, pub impl_error: FeatureConfig<'a>, pub impl_embedded_can_frame: FeatureConfig<'a>, pub check_ranges: FeatureConfig<'a>, pub allow_dead_code: bool, pub padding_bit_value: bool, pub attribute_structs: &'a [AttributeStruct<'a>],
}
Expand description

Code generator configuration. See module-level docs for an example.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§dbc_name: &'a str

Name of the dbc-file. Used for generated docs only.

§dbc_content: &'a str

Content of a dbc-file as a UTF-8 string. Use can_dbc::decode_cp1252 or other encodings if needed.

§debug_prints: bool

Optional: Print debug info to stdout while generating code. Default: false.

§impl_debug: FeatureConfig<'a>

Optional: impl Debug for generated types. Default: Never.

§impl_defmt: FeatureConfig<'a>

Optional: impl defmt::Format for generated types. Default: Never.

§impl_arbitrary: FeatureConfig<'a>

Optional: impl Arbitrary for generated types. Default: Never.

§impl_serde: FeatureConfig<'a>

Optional: impl Serialize and impl Deserialize for generated types.. Default: Never.

§impl_error: FeatureConfig<'a>

Optional: impl core::error::Error for the generated CanError type. Default: Never.

§impl_embedded_can_frame: FeatureConfig<'a>

Optional: Generate embedded_can::Frame impl for each frame. Default: Always

§check_ranges: FeatureConfig<'a>

Optional: Validate min and max values in generated signal setters. Default: Always

§allow_dead_code: bool

Optional: Allow dead code in the generated module. Default: false.

§padding_bit_value: bool

Optional: Padding bit value used; set all unused bits to 1 if true else to 0. Default: false.

§attribute_structs: &'a [AttributeStruct<'a>]

Optional: User-defined structs populated from DBC attributes. These are emitted as associated constants in the generated message types. Default: empty.

Implementations§

Source§

impl<'a> Config<'a>

Source

pub fn builder() -> ConfigBuilder<'a, ((), (), (), (), (), (), (), (), (), (), (), (), ())>

Create a builder for building Config. On the builder, call .dbc_name(...), .dbc_content(...), .debug_prints(...)(optional), .impl_debug(...)(optional), .impl_defmt(...)(optional), .impl_arbitrary(...)(optional), .impl_serde(...)(optional), .impl_error(...)(optional), .impl_embedded_can_frame(...)(optional), .check_ranges(...)(optional), .allow_dead_code(...)(optional), .padding_bit_value(...)(optional), .attribute_structs(...)(optional) to set the values of the fields. Finally, call .build() to create the instance of Config.

Source§

impl Config<'_>

Source

pub fn generate(self) -> Result<String>

Generate Rust structs matching DBC input description and return as String

Source

pub fn write(self, out: impl Write) -> Result<()>

Generate Rust structs matching DBC input description and write to out

Source

pub fn write_to_file<P: AsRef<Path>>(self, path: P) -> Result<()>

Generate Rust structs matching DBC input description and write to file at path

Auto Trait Implementations§

§

impl<'a> Freeze for Config<'a>

§

impl<'a> RefUnwindSafe for Config<'a>

§

impl<'a> Send for Config<'a>

§

impl<'a> Sync for Config<'a>

§

impl<'a> Unpin for Config<'a>

§

impl<'a> UnsafeUnpin for Config<'a>

§

impl<'a> UnwindSafe for Config<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.