dbc_rs/version/mod.rs
1mod core;
2mod parse;
3#[cfg(feature = "std")]
4mod serialize;
5
6#[cfg(feature = "std")]
7mod builder;
8
9use crate::{MAX_NAME_SIZE, compat::String};
10
11/// Represents a version string from a DBC file.
12///
13/// The `VERSION` statement in a DBC file specifies the database version.
14/// This struct stores the version string as a borrowed reference.
15///
16/// # Examples
17///
18/// ```rust,no_run
19/// use dbc_rs::Dbc;
20///
21/// let dbc_content = r#"VERSION "1.0"
22///
23/// BU_: ECM
24///
25/// BO_ 256 Engine : 8 ECM
26/// SG_ RPM : 0|16@1+ (0.25,0) [0|8000] "rpm"
27/// "#;
28///
29/// let dbc = Dbc::parse(dbc_content)?;
30/// if let Some(version) = dbc.version() {
31/// // Access the raw string
32/// assert_eq!(version.as_str(), "1.0");
33/// // Display trait is available with std feature
34/// #[cfg(feature = "std")]
35/// {
36/// println!("DBC version: {}", version);
37/// }
38/// }
39/// # Ok::<(), dbc_rs::Error>(())
40/// ```
41///
42/// # Format
43///
44/// The version string can be any sequence of printable characters enclosed in quotes.
45/// Common formats include:
46/// - `"1.0"` - Simple semantic version
47/// - `"1.2.3"` - Full semantic version
48/// - `"1.0-beta"` - Version with suffix
49/// - `""` - Empty version string (allowed)
50#[derive(Debug, Clone, PartialEq, Eq, Hash)]
51pub struct Version {
52 version: String<{ MAX_NAME_SIZE }>,
53}
54
55#[cfg(feature = "std")]
56pub use builder::VersionBuilder;