pub struct Local { /* private fields */ }Expand description
Local config stored in ~/.config/crev
This managed IDs, local proof repository, etc.
Implementations§
Source§impl Local
impl Local
Sourcepub fn load_db(&self) -> Result<ProofDB, Error>
pub fn load_db(&self) -> Result<ProofDB, Error>
Load all reviews and trust proofs for the current user
Sourcepub fn config_root(&self) -> &Path
pub fn config_root(&self) -> &Path
Where the config is stored
Sourcepub fn cache_root(&self) -> &Path
pub fn cache_root(&self) -> &Path
Where temporary files are stored
Sourcepub fn auto_create() -> Result<Self, Error>
pub fn auto_create() -> Result<Self, Error>
Fails if it already exists. See auto_create_or_open()
Sourcepub fn auto_create_or_open() -> Result<Self, Error>
pub fn auto_create_or_open() -> Result<Self, Error>
Load the database from disk, or create one if needed.
Sourcepub fn read_current_id(&self) -> Result<Id, Error>
pub fn read_current_id(&self) -> Result<Id, Error>
Load config, and return Id configured as the current one
Sourcepub fn read_current_id_opt(&self) -> Result<Option<Id>, Error>
pub fn read_current_id_opt(&self) -> Result<Option<Id>, Error>
Load config, and return Id configured as the current one
Sourcepub fn get_for_id_from_str_opt(
&self,
id_str: Option<&str>,
) -> Result<Option<Id>, Error>
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_stris given and parses correctly - convert to Id. - otherwise return current id
pub fn get_for_id_from_str(&self, id_str: Option<&str>) -> Result<Id, Error>
Sourcepub fn save_current_id(&self, id: &Id) -> Result<(), Error>
pub fn save_current_id(&self, id: &Id) -> Result<(), Error>
Load config, update which Id is the current one, and save.
Sourcepub fn user_dir_path(&self) -> PathBuf
pub fn user_dir_path(&self) -> PathBuf
Same as get_root_path()
Sourcepub fn user_ids_path(&self) -> PathBuf
pub fn user_ids_path(&self) -> PathBuf
Directory where yaml files for user identities are stored
Sourcepub fn user_ids_path_opt(&self) -> Option<PathBuf>
pub fn user_ids_path_opt(&self) -> Option<PathBuf>
Like Self::user_ids_path but checks if the dir exists
Sourcepub fn user_proofs_path(&self) -> PathBuf
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
Sourcepub fn user_proofs_path_opt(&self) -> Option<PathBuf>
pub fn user_proofs_path_opt(&self) -> Option<PathBuf>
Like user_proofs_path but checks if the dir exists
Sourcepub fn get_current_user_public_ids(&self) -> Result<Vec<PublicId>, Error>
pub fn get_current_user_public_ids(&self) -> Result<Vec<PublicId>, Error>
Returns public Ids which belong to the current user.
Sourcepub fn cache_remotes_path(&self) -> PathBuf
pub fn cache_remotes_path(&self) -> PathBuf
Path where git checkouts of other people’s proof repos are stored
Sourcepub fn sanitized_crate_copy(
&self,
source: RegistrySource<'_>,
name: &str,
version: &Version,
src_dir: &Path,
) -> Result<PathBuf, Error>
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
Sourcepub fn latest_review_activity(&self) -> Option<LatestReviewActivity>
pub fn latest_review_activity(&self) -> Option<LatestReviewActivity>
Most recent in-progress review
Sourcepub fn record_review_activity(
&self,
source: RegistrySource<'_>,
name: &str,
version: &Version,
activity: &ReviewActivity,
) -> Result<(), Error>
pub fn record_review_activity( &self, source: RegistrySource<'_>, name: &str, version: &Version, activity: &ReviewActivity, ) -> Result<(), Error>
Save activity (in-progress review) to disk
Sourcepub fn read_review_activity(
&self,
source: RegistrySource<'_>,
name: &str,
version: &Version,
) -> Result<Option<ReviewActivity>, Error>
pub fn read_review_activity( &self, source: RegistrySource<'_>, name: &str, version: &Version, ) -> Result<Option<ReviewActivity>, Error>
Load activity (in-progress review) from disk
Sourcepub fn load_user_config(&self) -> Result<UserConfig, Error>
pub fn load_user_config(&self) -> Result<UserConfig, Error>
Just returns the config, doesn’t change anything
Sourcepub fn store_user_config(&self, config: &UserConfig) -> Result<(), Error>
pub fn store_user_config(&self, config: &UserConfig) -> Result<(), Error>
Writes the config to disk AND sets it as the current one
Sourcepub fn get_current_userid(&self) -> Result<Id, Error>
pub fn get_current_userid(&self) -> Result<Id, Error>
Id in the config
Sourcepub fn read_locked_id(&self, id: &Id) -> Result<LockedId, Error>
pub fn read_locked_id(&self, id: &Id) -> Result<LockedId, Error>
Just reads the yaml file, doesn’t change any state
Sourcepub fn read_current_locked_id_opt(&self) -> Result<Option<LockedId>, Error>
pub fn read_current_locked_id_opt(&self) -> Result<Option<LockedId>, Error>
Just reads the yaml file, doesn’t change any state
Sourcepub fn read_current_locked_id(&self) -> Result<LockedId, Error>
pub fn read_current_locked_id(&self) -> Result<LockedId, Error>
Just reads the yaml file, doesn’t change any state
Sourcepub fn read_current_unlocked_id_opt(
&self,
passphrase_callback: PassphraseFn<'_>,
) -> Result<Option<UnlockedId>, Error>
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
Sourcepub fn read_current_unlocked_id(
&self,
passphrase_callback: PassphraseFn<'_>,
) -> Result<UnlockedId, Error>
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
Sourcepub fn read_unlocked_id(
&self,
id: &Id,
passphrase_callback: PassphraseFn<'_>,
) -> Result<UnlockedId, Error>
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
Sourcepub fn change_locked_id_url(
&self,
id: &mut LockedId,
git_https_url: &str,
use_https_push: bool,
warnings: &mut Vec<Warning>,
) -> Result<(), Error>
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.
Sourcepub fn save_locked_id(&self, id: &LockedId) -> Result<(), Error>
pub fn save_locked_id(&self, id: &LockedId) -> Result<(), Error>
Writes the Id to disk, doesn’t change any state
Sourcepub fn clone_proof_dir_from_git(
&self,
git_https_url: &str,
use_https_push: bool,
warnings: &mut Vec<Warning>,
) -> Result<(), Error>
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.
Sourcepub fn init_repo_readme_using_template(&self) -> Result<(), Error>
pub fn init_repo_readme_using_template(&self) -> Result<(), Error>
Inits repo in get_proofs_dir_path()
Sourcepub fn get_proofs_dir_path_for_url(&self, url: &Url) -> Result<PathBuf, Error>
pub fn get_proofs_dir_path_for_url(&self, url: &Url) -> Result<PathBuf, Error>
Dir unique to this URL, inside user_proofs_path()
Sourcepub fn get_proofs_dir_path(&self) -> Result<PathBuf, Error>
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
Sourcepub fn get_proofs_dir_path_opt(&self) -> Result<Option<PathBuf>, Error>
pub fn get_proofs_dir_path_opt(&self) -> Result<Option<PathBuf>, Error>
This function derives path from current user’s URL
Sourcepub fn build_trust_proof(
&self,
from_id: &PublicId,
ids: Vec<Id>,
trust_level: TrustLevel,
override_: Vec<OverrideItem>,
) -> Result<Trust, Error>
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)
Sourcepub fn fetch_url(&self, url: &str) -> Result<(), Error>
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
Sourcepub fn fetch_url_into(&self, url: &str, db: &mut ProofDB) -> Result<(), Error>
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)
pub fn trust_set_for_id( &self, for_id: Option<&str>, params: &TrustDistanceParams, db: &ProofDB, ) -> Result<TrustSet, Error>
Sourcepub fn fetch_new_trusted(
&self,
trust_params: TrustDistanceParams,
for_id: Option<&str>,
warnings: &mut Vec<Warning>,
) -> Result<(), Error>
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
Sourcepub fn fetch_trusted(
&self,
trust_params: TrustDistanceParams,
for_id: Option<&str>,
warnings: &mut Vec<Warning>,
) -> Result<(), Error>
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
Sourcepub fn get_remote_git_cache_path(&self, url: &str) -> Result<PathBuf, Error>
pub fn get_remote_git_cache_path(&self, url: &str) -> Result<PathBuf, Error>
Per-url directory in cache_remotes_path()
Sourcepub fn fetch_remote_git(&self, url: &str) -> Result<PathBuf, Error>
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.
Sourcepub fn import_proof_dir_and_print_counts(
&self,
dir: &Path,
url: &str,
db: &mut ProofDB,
) -> Result<(), Error>
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
Sourcepub fn fetch_all(&self, warnings: &mut Vec<Warning>) -> Result<(), Error>
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.
pub fn url_for_repo_at_path(repo: &Path) -> Result<String, Error>
Sourcepub fn run_git(
&self,
args: Vec<OsString>,
warnings: &mut Vec<Warning>,
) -> Result<ExitStatus, Error>
pub fn run_git( &self, args: Vec<OsString>, warnings: &mut Vec<Warning>, ) -> Result<ExitStatus, Error>
Run arbitrary git command in get_proofs_dir_path()
Sourcepub fn store_config_open_cmd(&self, cmd: String) -> Result<(), Error>
pub fn store_config_open_cmd(&self, cmd: String) -> Result<(), Error>
set open_cmd in the config
Sourcepub fn proof_dir_git_add_path(&self, rel_path: &Path) -> Result<(), Error>
pub fn proof_dir_git_add_path(&self, rel_path: &Path) -> Result<(), Error>
The path must be inside get_proofs_dir_path()
Sourcepub fn proof_dir_commit(&self, commit_msg: &str) -> Result<(), Error>
pub fn proof_dir_commit(&self, commit_msg: &str) -> Result<(), Error>
Add a commit to user’s proof repo
Sourcepub fn show_current_id(&self) -> Result<(), Error>
pub fn show_current_id(&self) -> Result<(), Error>
Prints read_current_locked_id
Sourcepub 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>
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
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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