Local

Struct Local 

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

Local config stored in ~/.config/crev

This managed IDs, local proof repository, etc.

Implementations§

Source§

impl Local

Source

pub fn load_db(&self) -> Result<ProofDB, Error>

Load all reviews and trust proofs for the current user

Source

pub fn config_root(&self) -> &Path

Where the config is stored

Source

pub fn data_root(&self) -> &Path

Where the data is stored

Source

pub fn cache_root(&self) -> &Path

Where temporary files are stored

Source

pub fn auto_open() -> Result<Self, Error>

Fails if it doesn’t exist. See auto_create_or_open()

Source

pub fn auto_create() -> Result<Self, Error>

Fails if it already exists. See auto_create_or_open()

Source

pub fn auto_create_or_open() -> Result<Self, Error>

Load the database from disk, or create one if needed.

Source

pub fn read_current_id(&self) -> Result<Id, Error>

Load config, and return Id configured as the current one

Source

pub fn read_current_id_opt(&self) -> Result<Option<Id>, Error>

Load config, and return Id configured as the current one

Source

pub fn get_for_id_from_str_opt( &self, id_str: Option<&str>, ) -> Result<Option<Id>, Error>

Calculate for_id that is used in a lot of operations

  • if id_str is given and parses correctly - convert to Id.
  • otherwise return current id
Source

pub fn get_for_id_from_str(&self, id_str: Option<&str>) -> Result<Id, Error>

Source

pub fn save_current_id(&self, id: &Id) -> Result<(), Error>

Load config, update which Id is the current one, and save.

Source

pub fn user_dir_path(&self) -> PathBuf

Same as get_root_path()

Source

pub fn user_ids_path(&self) -> PathBuf

Directory where yaml files for user identities are stored

Source

pub fn user_ids_path_opt(&self) -> Option<PathBuf>

Like Self::user_ids_path but checks if the dir exists

Source

pub fn user_proofs_path(&self) -> PathBuf

Directory where git checkouts for user’s own proof repos are stored

This is separate from cache of other people’s proofs

Source

pub fn user_proofs_path_opt(&self) -> Option<PathBuf>

Like user_proofs_path but checks if the dir exists

Source

pub fn get_current_user_public_ids(&self) -> Result<Vec<PublicId>, Error>

Returns public Ids which belong to the current user.

Source

pub fn cache_remotes_path(&self) -> PathBuf

Path where git checkouts of other people’s proof repos are stored

Source

pub fn sanitized_crate_copy( &self, source: RegistrySource<'_>, name: &str, version: &Version, src_dir: &Path, ) -> Result<PathBuf, Error>

Copy crate for review, neutralizing hidden or dangerous files

Source

pub fn latest_review_activity(&self) -> Option<LatestReviewActivity>

Most recent in-progress review

Source

pub fn record_review_activity( &self, source: RegistrySource<'_>, name: &str, version: &Version, activity: &ReviewActivity, ) -> Result<(), Error>

Save activity (in-progress review) to disk

Source

pub fn read_review_activity( &self, source: RegistrySource<'_>, name: &str, version: &Version, ) -> Result<Option<ReviewActivity>, Error>

Load activity (in-progress review) from disk

Source

pub fn load_user_config(&self) -> Result<UserConfig, Error>

Just returns the config, doesn’t change anything

Source

pub fn store_user_config(&self, config: &UserConfig) -> Result<(), Error>

Writes the config to disk AND sets it as the current one

Source

pub fn get_current_userid(&self) -> Result<Id, Error>

Id in the config

Source

pub fn get_current_userid_opt(&self) -> Result<Option<Id>, Error>

Id in the config

Source

pub fn read_locked_id(&self, id: &Id) -> Result<LockedId, Error>

Just reads the yaml file, doesn’t change any state

Source

pub fn read_current_locked_id_opt(&self) -> Result<Option<LockedId>, Error>

Just reads the yaml file, doesn’t change any state

Source

pub fn read_current_locked_id(&self) -> Result<LockedId, Error>

Just reads the yaml file, doesn’t change any state

Source

pub fn read_current_unlocked_id_opt( &self, passphrase_callback: PassphraseFn<'_>, ) -> Result<Option<UnlockedId>, Error>

Just reads the yaml file and unlocks it, doesn’t change any state

Source

pub fn read_current_unlocked_id( &self, passphrase_callback: PassphraseFn<'_>, ) -> Result<UnlockedId, Error>

Just reads the yaml file and unlocks it, doesn’t change anything

Source

pub fn read_unlocked_id( &self, id: &Id, passphrase_callback: PassphraseFn<'_>, ) -> Result<UnlockedId, Error>

Just reads the yaml file and unlocks it, doesn’t change anything

Asks for passphrase up to 5 times

Source

pub fn change_locked_id_url( &self, id: &mut LockedId, git_https_url: &str, use_https_push: bool, warnings: &mut Vec<Warning>, ) -> Result<(), Error>

Changes the repo URL for the ID. Adopts existing temporary/local repo if any. Previous remote URL is abandoned. For crev id set-url command.

Source

pub fn save_locked_id(&self, id: &LockedId) -> Result<(), Error>

Writes the Id to disk, doesn’t change any state

Source

pub fn clone_proof_dir_from_git( &self, git_https_url: &str, use_https_push: bool, warnings: &mut Vec<Warning>, ) -> Result<(), Error>

Git clone or init new remote Github crev-proof repo for the current user.

Saves to user_proofs_path, so it’s trusted as user’s own proof repo.

Source

pub fn init_repo_readme_using_template(&self) -> Result<(), Error>

Inits repo in get_proofs_dir_path()

Source

pub fn get_proofs_dir_path_for_url(&self, url: &Url) -> Result<PathBuf, Error>

Dir unique to this URL, inside user_proofs_path()

Source

pub fn get_proofs_dir_path(&self) -> Result<PathBuf, Error>

Path where the proofs are stored under git repository.

This function derives path from current user’s URL

Source

pub fn get_proofs_dir_path_opt(&self) -> Result<Option<PathBuf>, Error>

This function derives path from current user’s URL

Source

pub fn build_trust_proof( &self, from_id: &PublicId, ids: Vec<Id>, trust_level: TrustLevel, override_: Vec<OverrideItem>, ) -> Result<Trust, Error>

Creates new unsigned trust proof object, not edited

Ensures the proof contains valid URLs for Ids where possible.

Currently ignores previous proofs

See trust.sign_by(ownid)

Source

pub fn fetch_url(&self, url: &str) -> Result<(), Error>

Fetch other people’s proof repository from a git URL, into the current database on disk

Source

pub fn fetch_url_into(&self, url: &str, db: &mut ProofDB) -> Result<(), Error>

Fetch other people’s proof repository from a git URL, directly into the given db (and disk too)

Source

pub fn trust_set_for_id( &self, for_id: Option<&str>, params: &TrustDistanceParams, db: &ProofDB, ) -> Result<TrustSet, Error>

Source

pub fn fetch_new_trusted( &self, trust_params: TrustDistanceParams, for_id: Option<&str>, warnings: &mut Vec<Warning>, ) -> Result<(), Error>

Fetch only repos that weren’t fetched before

Source

pub fn fetch_trusted( &self, trust_params: TrustDistanceParams, for_id: Option<&str>, warnings: &mut Vec<Warning>, ) -> Result<(), Error>

Fetch proof repo URLs of trusted Ids

Source

pub fn get_remote_git_cache_path(&self, url: &str) -> Result<PathBuf, Error>

Per-url directory in cache_remotes_path()

Source

pub fn fetch_remote_git(&self, url: &str) -> Result<PathBuf, Error>

Fetch a git proof repository

Returns url where it was cloned/fetched

Adds the repo to the local proof repo cache.

Source

pub fn import_proof_dir_and_print_counts( &self, dir: &Path, url: &str, db: &mut ProofDB, ) -> Result<(), Error>

Fetches and imports to the given db

Same as fetch_url_into, but with more stats

dir - where the proofs were downloaded to url - url from which it was fetched

Source

pub fn fetch_all(&self, warnings: &mut Vec<Warning>) -> Result<(), Error>

Fetch and discover proof repos. Like fetch_all_ids_recursively, but adds https://github.com/dpc/crev-proofs and repos in cache that didn’t belong to any Ids.

Source

pub fn url_for_repo_at_path(repo: &Path) -> Result<String, Error>

Source

pub fn run_git( &self, args: Vec<OsString>, warnings: &mut Vec<Warning>, ) -> Result<ExitStatus, Error>

Run arbitrary git command in get_proofs_dir_path()

Source

pub fn store_config_open_cmd(&self, cmd: String) -> Result<(), Error>

set open_cmd in the config

Source

pub fn proof_dir_git_add_path(&self, rel_path: &Path) -> Result<(), Error>

The path must be inside get_proofs_dir_path()

Source

pub fn proof_dir_commit(&self, commit_msg: &str) -> Result<(), Error>

Add a commit to user’s proof repo

Source

pub fn show_current_id(&self) -> Result<(), Error>

Prints read_current_locked_id

Source

pub fn generate_id( &self, url: Option<&str>, use_https_push: bool, read_new_passphrase: impl FnOnce() -> Result<String>, warnings: &mut Vec<Warning>, ) -> Result<LockedId, Error>

Generate a new identity in the local config.

It’s OK if the URL contains other identities. A new one will be added.

The callback should provide a passphrase

Source

pub fn switch_id(&self, id_str: &str) -> Result<(), Error>

Set given Id as the current one

Source

pub fn export_locked_id(&self, id_str: Option<String>) -> Result<String, Error>

See read_locked_id

Source

pub fn import_locked_id( &self, locked_id_serialized: &str, ) -> Result<PublicId, Error>

Parse LockedId’s YAML and write it to disk. See save_locked_id

Auto Trait Implementations§

§

impl !Freeze for Local

§

impl RefUnwindSafe for Local

§

impl Send for Local

§

impl Sync for Local

§

impl Unpin for Local

§

impl UnwindSafe for Local

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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