#[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
Text
The version is in the file’s text, in a place its format fixes.
Fields
Path
The version is a string at a key path in a TOML or JSON file.
Fields
Command
An external filter reads and writes the version.
Fields
read: CommandSpecPrints the version from the file on stdin.
write: CommandSpecPrints the new file from the file on stdin and VERCTL_VERSION.
Implementations§
Source§impl Driver
impl Driver
Sourcepub fn cargo() -> Result<Self>
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.
Sourcepub fn npm() -> Result<Self>
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.
Sourcepub fn source(&self, path: &Path) -> Result<String>
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.
Sourcepub fn accepts(&self, raw: &str, new_version: &str) -> Result<()>
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.
Sourcepub fn read(&self, raw: &str) -> Result<String>
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.
Trait Implementations§
impl Eq for Driver
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 Driverwhere
RawVecInner: Send,
impl Sync for Driverwhere
RawVecInner: Sync,
impl Unpin for Driver
impl UnsafeUnpin for Driverwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
impl UnwindSafe for Driverwhere
RawVecInner: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.