Struct Policy

Source
pub struct Policy { /* private fields */ }
Expand description

A policy for OpenPGP signatures in git.

A Policy governs state changes in git repositories. A state change is a change from one git commit with a policy embedded into it to the next commit, which may change the policy, the source, or both.

Implementations§

Source§

impl Policy

Source

pub fn parse_bytes<D: AsRef<[u8]>>(bytes: D) -> Result<Self>

Source

pub fn read_file<P: AsRef<Path>>(path: P) -> Result<Policy>

Reads the policy from the given path.

Source

pub fn read_file_or_default<P: AsRef<Path>>(path: P) -> Result<Policy>

Reads the policy from the given path.

Source

pub fn read_from_working_dir() -> Result<Policy>

Reads the policy from the current git working directory.

Default to the empty policy if the work directory doesn’t contain a policy.

Source

pub fn read_bytes_from_commit(git: &Repository, commit: &Oid) -> Result<Vec<u8>>

Reads the policy from the given git commit.

Source

pub fn read_from_commit(git: &Repository, commit: &Oid) -> Result<Self>

Reads the policy from the given git commit.

Source

pub fn write<P: AsRef<Path>>(&self, path: P) -> Result<()>

Writes the policy into a file with the given path.

Source

pub fn write_to_working_dir(&self) -> Result<()>

Writes the policy to the current git working directory.

Source

pub fn version(&self) -> usize

The policy version.

Source

pub fn commit_goodlist(&self) -> &BTreeSet<String>

Set of commits that is assumed to be good.

The commits will pass verification even if it would fail for whatever reason.

To change this set, you need the audit right.

Source

pub fn commit_goodlist_mut(&mut self) -> &mut BTreeSet<String>

Set of commits that is assumed to be good.

The commits will pass verification even if it would fail for whatever reason.

To change this set, you need the audit right.

Source

pub fn authorization(&self) -> &BTreeMap<String, Authorization>

Set of authorizations.

The key is a free-form, human-readable identifier for the authorization.

Source

pub fn authorization_mut(&mut self) -> &mut BTreeMap<String, Authorization>

Set of authorizations.

The key is a free-form, human-readable identifier for the authorization.

Source

pub fn diff<'f, 't>(&'f self, other: &'t Policy) -> Result<Diff<'f, 't>>

Computes the difference between this policy and other.

Source

pub fn verify( &self, git: &Repository, commit_id: &Oid, commit_policy: &Policy, signer_keys: &mut BTreeSet<Fingerprint>, primary_uids: &mut BTreeSet<UserID>, ) -> Result<Vec<Result<(String, Signature, Cert, Fingerprint)>>>

Verifies that the given commit adheres to this policy.

During verification, the key(s) used are stored in signer_keys, and the primary user id of the issuing cert at the time of the signing is stored in primary_uids. This information can be used to prune certs in a policy.

If the commit is goodlisted, this function returns Ok with an empty vector of verification results.

Source

pub fn verify_archive<T, S>( &self, signature: S, archive: T, ) -> Result<Vec<Result<(String, Signature, Cert, Fingerprint)>>>
where T: AsRef<[u8]>, S: AsRef<[u8]>,

Trait Implementations§

Source§

impl Clone for Policy

Source§

fn clone(&self) -> Policy

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for Policy

Source§

fn default() -> Policy

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

impl<'de> Deserialize<'de> for Policy

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Policy

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Policy

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Policy

Source§

impl 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 UnwindSafe for Policy

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

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

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T