Skip to main content

ReadOnlyKeyring

Struct ReadOnlyKeyring 

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

Read-only interface for querying a GPG keyring.

This type is returned by Keyring::with_homedir and only provides read operations (list_keys, list_signatures). Write operations require a Keyring which targets the system pacman keyring.

§Example

use pacman_key::Keyring;

let reader = Keyring::with_homedir("/custom/gnupg");
let keys = reader.list_keys().await?;

Implementations§

Source§

impl ReadOnlyKeyring

Source

pub async fn list_keys(&self) -> Result<Vec<Key>>

Lists all keys in the keyring.

Source

pub async fn list_signatures( &self, keyid: Option<&str>, ) -> Result<Vec<Signature>>

Lists signatures on keys in the keyring (non-checking --list-sigs).

If keyid is provided, lists signatures only for that key. Otherwise lists all signatures in the keyring. The status field of each Signature is None; use check_signatures to verify them.

Source

pub async fn check_signatures( &self, keyid: Option<&str>, ) -> Result<Vec<Signature>>

Lists and verifies signatures on keys (--check-sigs).

Like list_signatures but each Signature’s status is populated with the verification result.

Source

pub async fn export_keys(&self, keyids: &[&str]) -> Result<String>

Exports the given keys as an ASCII-armored block.

An empty keyids slice exports all public keys. Mirrors pacman-key --export.

Source

pub async fn fingerprints(&self, keyids: &[&str]) -> Result<Vec<String>>

Returns the fingerprints of the given keys (or all keys if empty).

Mirrors pacman-key --finger. Note list_keys already returns the same fingerprints alongside the full key data; this is a convenience for when only fingerprints are needed.

Source

pub async fn verify_signature( &self, sig: &Path, file: Option<&Path>, ) -> Result<VerifyResult>

Verifies a signature against the keyring.

sig is the (binary) signature file; file is the signed data for a detached signature (omit for an embedded one). Mirrors pacman-key --verify, which rejects ASCII-armored signatures.

Returns a VerifyResult; a bad signature is reported via good == false, not an error. Only an inability to run gpg or read the signature file produces an Err.

Source

pub async fn get_ownertrust(&self) -> Result<Vec<(String, OwnerTrust)>>

Reads owner-trust assignments via gpg --export-ownertrust.

Source

pub fn is_initialized(&self) -> Result<InitializationStatus>

Checks whether the keyring is initialized without spawning GPG.

Verifies the directory exists with mode 755 (as created by pacman-key --init; world-readable so unprivileged pacman can read the public keyring, pacman commit 4ef664f4) and contains a non-empty pubring.kbx or pubring.gpg plus trustdb.gpg. Symlinks are followed. Non-atomic and subject to TOCTOU races; use for informational purposes, not security decisions.

Auto Trait Implementations§

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> 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, 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.