pub struct Policy {
pub schema: String,
pub mode: Mode,
}Expand description
The compatibility policy, named and versioned.
use majordomus_cli::release::compat::{Impact, Policy, POLICY_SCHEMA};
use majordomus_cli::release::version::Version;
let policy = Policy::for_version(Version::parse("0.5.0").unwrap());
assert_eq!(policy.schema, POLICY_SCHEMA, "a verdict carries the rules it was reached under");
assert_eq!(policy.required_of(Impact::Major), Impact::Minor);Fields§
§schema: Stringmajordomus/version-policy/v1.
mode: ModeWhich rule is in force, decided by the baseline version alone.
Implementations§
Source§impl Policy
impl Policy
Sourcepub fn for_version(base: Version) -> Policy
pub fn for_version(base: Version) -> Policy
The policy that governs a project at this version.
use majordomus_cli::release::compat::{Mode, Policy};
use majordomus_cli::release::version::Version;
// the baseline decides the mode, not the version being written
assert_eq!(Policy::for_version(Version::parse("0.1.0").unwrap()).mode, Mode::Pre1_0Strict);
assert_eq!(Policy::for_version(Version::parse("2.3.4").unwrap()).mode, Mode::Semver);Sourcepub fn required_of(&self, implied: Impact) -> Impact
pub fn required_of(&self, implied: Impact) -> Impact
The smallest release this impact is allowed to ship as.
An unchanged surface owes nothing under either mode. This runs over every tree, not only over a release, and most commits are behind the boundary: demanding a bump for each of them would make the gate a thing to be worked around within a day.
use majordomus_cli::release::compat::{Impact, Policy};
use majordomus_cli::release::version::Version;
let pre = Policy::for_version(Version::parse("0.5.0").unwrap());
assert_eq!(pre.required_of(Impact::None), Impact::None);
assert_eq!(pre.required_of(Impact::Minor), Impact::Minor);
assert_eq!(pre.required_of(Impact::Major), Impact::Minor, "0.x floors a removal at a minor");
let one = Policy::for_version(Version::parse("1.0.0").unwrap());
assert_eq!(one.required_of(Impact::Major), Impact::Major);Sourcepub fn statement(&self) -> &'static str
pub fn statement(&self) -> &'static str
How this policy explains itself, in the plan and in --explain.
use majordomus_cli::release::compat::Policy;
use majordomus_cli::release::version::Version;
let policy = Policy::for_version(Version::parse("0.5.0").unwrap());
assert!(policy.statement().contains("below 1.0.0"));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Policy
impl<'de> Deserialize<'de> for Policy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Policy
Source§impl JsonSchema for Policy
impl JsonSchema for Policy
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreimpl StructuralPartialEq for Policy
Auto Trait Implementations§
impl Freeze for Policy
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnsafeUnpin for Policy
impl UnwindSafe for Policy
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.