Skip to main content

Driver

Enum Driver 

Source
#[non_exhaustive]
pub enum Driver { Text { text: Text, after: Option<String>, }, Path { format: Format, keys: Vec<String>, after: Option<String>, }, Command { read: CommandSpec, write: CommandSpec, after: Option<String>, }, }
Expand description

How a package’s version is read and written.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Text

The version is in the file’s text, in a place its format fixes.

Fields

§text: Text

Which format.

§after: Option<String>

Follow-up command to run after the bump, such as a lockfile refresh.

§

Path

The version is a string at a key path in a TOML or JSON file.

Fields

§format: Format

The file format.

§keys: Vec<String>

Dotted key paths tried in order; the first that contains a string wins.

§after: Option<String>

Follow-up command to run after the bump, such as a lockfile refresh.

§

Command

An external filter reads and writes the version.

Fields

§read: CommandSpec

Prints the version from the file on stdin.

§write: CommandSpec

Prints the new file from the file on stdin and VERCTL_VERSION.

§after: Option<String>

Follow-up command to run after the bump, such as a lockfile refresh.

Implementations§

Source§

impl Driver

Source

pub fn cargo() -> Result<Self>

The stock driver for Cargo.toml.

§Errors

Returns an error only if the built-in definition fails validation, which a test guards against.

Source

pub fn npm() -> Result<Self>

The stock driver for package.json.

§Errors

Returns an error only if the built-in definition fails validation, which a test guards against.

Source

pub fn source(&self, path: &Path) -> Result<String>

The text of path, the file this driver reads and writes.

A VERSION file that does not exist yet is empty text. Empty text reads as 0.0.0, so a new package needs no file before its first release. version creates the file, and check leaves the tree as it was.

The file’s directory must exist. A package whose directory is missing has a wrong path, and version would otherwise fail halfway through its writes.

§Errors

Returns an error naming path when it cannot be read. A missing file is an error unless the driver is a VERSION file whose directory exists.

Source

pub fn after(&self) -> Option<&str>

The follow-up command to run after the bump, if any.

Source

pub fn accepts(&self, raw: &str, new_version: &str) -> Result<()>

Refuse new_version when the file’s own format forbids it, before anything is written, so version --dry-run refuses it too.

§Errors

For a go.mod, returns an error when the new major version and the module path’s /vN suffix conflict. Other drivers accept any version.

Source

pub fn read(&self, raw: &str) -> Result<String>

The current version in raw.

§Errors

For a path driver, returns an error when raw is not valid TOML or JSON, or when none of the configured keys contains a string. For a command driver, returns an error when the filter cannot be run, times out, exits unsuccessfully, or prints non-UTF-8 or oversized output.

Source

pub fn write(&self, raw: &str, new_version: &str) -> Result<String>

raw with the version replaced by new_version.

§Errors

Fails on the same conditions as Driver::read: unparsable input, no configured key containing a string, or a command filter that fails.

Trait Implementations§

Source§

impl Clone for Driver

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Driver

Source§

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

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

impl Eq for Driver

Source§

impl PartialEq for Driver

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Driver

Auto Trait Implementations§

§

impl Forget for Driver

§

impl Freeze for Driver

§

impl Move for Driver

§

impl RefUnwindSafe for Driver

§

impl Send for Driver
where RawVecInner: Send,

§

impl Sync for Driver
where RawVecInner: Sync,

§

impl Unpin for Driver
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Driver

§

impl UnwindSafe for Driver
where RawVecInner: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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, O> Matches<O> for T
where T: PartialEq<O>,

Source§

fn validate_matches(&self, other: &O) -> bool

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.