pub struct Local { /* private fields */ }
Expand description
Local config stored in ~/.config/crev
This managed IDs, local proof repository, etc.
Implementations
sourceimpl Local
impl Local
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_str
is 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_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: &str,
name: &str,
version: &Version,
src_dir: &Path
) -> Result<PathBuf, Error>
pub fn sanitized_crate_copy(
&self,
source: &str,
name: &str,
version: &Version,
src_dir: &Path
) -> Result<PathBuf, Error>
Copy crate for review, neutralizing hidden or dangerous files
sourcepub fn record_review_activity(
&self,
source: &str,
name: &str,
version: &Version,
activity: &ReviewActivity
) -> Result<(), Error>
pub fn record_review_activity(
&self,
source: &str,
name: &str,
version: &Version,
activity: &ReviewActivity
) -> Result<(), Error>
Save activity (in-progress review) to disk
sourcepub fn read_review_activity(
&self,
source: &str,
name: &str,
version: &Version
) -> Result<Option<ReviewActivity>, Error>
pub fn read_review_activity(
&self,
source: &str,
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
) -> Result<(), Error>
pub fn change_locked_id_url(
&self,
id: &mut LockedId,
git_https_url: &str,
use_https_push: bool
) -> 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
) -> Result<(), Error>
pub fn clone_proof_dir_from_git(
&self,
git_https_url: &str,
use_https_push: bool
) -> 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 repostiory 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 repostiory 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>
) -> Result<(), Error>
pub fn fetch_new_trusted(
&self,
trust_params: TrustDistanceParams,
for_id: Option<&str>
) -> Result<(), Error>
Fetch only repos that weren’t fetched before
sourcepub fn fetch_trusted(
&self,
trust_params: TrustDistanceParams,
for_id: Option<&str>
) -> Result<(), Error>
pub fn fetch_trusted(
&self,
trust_params: TrustDistanceParams,
for_id: Option<&str>
) -> 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) -> Result<(), Error>
pub fn fetch_all(&self) -> 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.
sourcepub fn run_git(&self, args: Vec<OsString>) -> Result<ExitStatus, Error>
pub fn run_git(&self, args: Vec<OsString>) -> 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 load_db(&self) -> Result<ProofDB, Error>
pub fn load_db(&self) -> Result<ProofDB, Error>
Create a new proofdb, and populate it with local repo and cache content.
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>
) -> Result<LockedId, Error>
pub fn generate_id(
&self,
url: Option<&str>,
use_https_push: bool,
read_new_passphrase: impl FnOnce() -> Result<String>
) -> 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
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Local
impl Send for Local
impl Sync for Local
impl Unpin for Local
impl UnwindSafe for Local
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more