pub struct VersionBuilder { /* private fields */ }Expand description
Builder for creating Version programmatically.
This builder allows you to construct version strings when building DBC files programmatically by specifying a complete version string.
§Examples
use dbc_rs::VersionBuilder;
// Direct version string
let version = VersionBuilder::new().version("1.0").build()?;
assert_eq!(version.as_str(), "1.0");
// Semantic versioning (as a string)
let version2 = VersionBuilder::new()
.version("1.2.3")
.build()?;
assert_eq!(version2.as_str(), "1.2.3");§Feature Requirements
This builder requires the std feature to be enabled.
Implementations§
Source§impl VersionBuilder
impl VersionBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new VersionBuilder with no version set.
§Examples
use dbc_rs::VersionBuilder;
let builder = VersionBuilder::new();
// Must set version before building
let version = builder.version("1.0").build()?;Sourcepub fn build(self) -> Result<Version>
pub fn build(self) -> Result<Version>
Builds the Version from the builder configuration.
This validates that a version has been set and constructs a Version instance
with static lifetime.
§Returns
Returns Ok(Version) if successful, or Err(Error::Version) if:
- No version has been set (empty version)
§Examples
use dbc_rs::VersionBuilder;
// Build with version string
let version = VersionBuilder::new()
.version("1.0")
.build()?;
assert_eq!(version.as_str(), "1.0");§Errors
use dbc_rs::VersionBuilder;
// Missing version
let result = VersionBuilder::new().build();
assert!(result.is_err());
// Empty string is allowed
let version = VersionBuilder::new().version("").build()?;
assert_eq!(version.as_str(), "");Trait Implementations§
Source§impl Debug for VersionBuilder
impl Debug for VersionBuilder
Auto Trait Implementations§
impl Freeze for VersionBuilder
impl RefUnwindSafe for VersionBuilder
impl Send for VersionBuilder
impl Sync for VersionBuilder
impl Unpin for VersionBuilder
impl UnwindSafe for VersionBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more