pub struct LogState { /* private fields */ }
Expand description
Calculated state for a package log.
Implementations§
Source§impl LogState
impl LogState
Sourcepub fn head(&self) -> &Option<Head>
pub fn head(&self) -> &Option<Head>
Gets the current head of the state.
Returns None
if no records have been validated yet.
Sourcepub fn validate(
self,
record: &ProtoEnvelope<PackageRecord>,
) -> Result<Self, ValidationError>
pub fn validate( self, record: &ProtoEnvelope<PackageRecord>, ) -> Result<Self, ValidationError>
Validates an individual package record.
It is expected that validate
is called in order of the
records in the log.
Note that on failure, the log state is consumed to prevent invalid state from being used in future validations.
Sourcepub fn releases(&self) -> impl Iterator<Item = &Release>
pub fn releases(&self) -> impl Iterator<Item = &Release>
Gets the releases known to the state.
The releases are returned in package log order.
Yanked releases are included.
Sourcepub fn release(&self, version: &Version) -> Option<&Release>
pub fn release(&self, version: &Version) -> Option<&Release>
Gets the release with the given version.
Returns None
if a release with the given version does not exist.
Sourcepub fn find_latest_release(&self, req: &VersionReq) -> Option<&Release>
pub fn find_latest_release(&self, req: &VersionReq) -> Option<&Release>
Finds the latest release matching the given version requirement.
Releases that have been yanked are not considered.
Sourcepub fn public_key(&self, key_id: &KeyID) -> Option<&PublicKey>
pub fn public_key(&self, key_id: &KeyID) -> Option<&PublicKey>
Gets the public key of the given key id.
Returns None
if the key id is not recognized.
Sourcepub fn key_permissions(&self, key_id: &KeyID) -> Option<&IndexSet<Permission>>
pub fn key_permissions(&self, key_id: &KeyID) -> Option<&IndexSet<Permission>>
Gets the key permissions.
Returns None
if the key id is not recognized.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LogState
impl<'de> Deserialize<'de> for LogState
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>,
Source§impl Validator for LogState
impl Validator for LogState
Source§type Record = PackageRecord
type Record = PackageRecord
Source§type Error = ValidationError
type Error = ValidationError
impl Eq for LogState
impl StructuralPartialEq for LogState
Auto Trait Implementations§
impl Freeze for LogState
impl RefUnwindSafe for LogState
impl Send for LogState
impl Sync for LogState
impl Unpin for LogState
impl UnwindSafe for LogState
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.