VersionBuilder

Struct VersionBuilder 

Source
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

Source

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()?;
Source

pub fn version(self, version: impl AsRef<str>) -> Self

Sets the complete version string.

§Arguments
  • version - The complete version string (e.g., “1.0”, “1.2.3”, “1.0-beta”)
§Examples
use dbc_rs::VersionBuilder;

let version = VersionBuilder::new()
    .version("1.2.3")
    .build()?;
assert_eq!(version.as_str(), "1.2.3");
Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for VersionBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.