pub struct Vigor {
pub config: ConfigSchema,
pub path: PathBuf,
}Expand description
Configuration and path information for agent structure. Includes implementations for agent logic.
Consume implemented methods for initialization, see new method.
Fields§
§config: ConfigSchemaConfiguration structure.
path: PathBufPath to configuration file.
Implementations§
Source§impl Vigor
impl Vigor
Sourcepub fn read(&mut self) -> Result<(), Error>
pub fn read(&mut self) -> Result<(), Error>
Reads configuration from disk. Does not check to see if path to configuration file exists.
Sourcepub fn init(&mut self) -> Result<(), Error>
pub fn init(&mut self) -> Result<(), Error>
Runs initialization for Vigor agent.
If configuration does not exist, write method is called.
If configuration does exist, read method is called.
Sourcepub fn new() -> Result<Vigor, Error>
pub fn new() -> Result<Vigor, Error>
Creates a new Vigor agent.
The default configuration structure as JSON appears as follows:
{
"preferred_username": "nobody",
"email": "nobody@localhost",
"password": "hunter2",
"ed25519": {
"public": "/path/to/your/keys/vigor.pem.pub",
"private": "/path/to/your/keys/vigor.pem",
"enabled": false
}
}§Examples
To initialize a new instance:
let mut agent = vigor_agent::Vigor::new().unwrap();
agent.init().unwrap();Sourcepub fn put(
&self,
host: &str,
share_email: bool,
use_password: bool,
use_ed25519: bool,
) -> Result<(), Error>
pub fn put( &self, host: &str, share_email: bool, use_password: bool, use_ed25519: bool, ) -> Result<(), Error>
Performs account creation to a Vigor host.
This method expects three booleans after the host argument for whether email, password, and/or Ed25519 should be shared, respectively. At least one authentication method must be shared.
§Examples
// assuming you already have an instance called "agent"
agent.put("http://example.com/claims/", true, true, true).unwrap();Sourcepub fn get(&self, host: &str, mode: AuthMode) -> Result<String, Error>
pub fn get(&self, host: &str, mode: AuthMode) -> Result<String, Error>
Performs token retrieval to a Vigor host.
§Examples
// assuming you already have an instance called "agent"
agent.get("http://example.com/claims/", vigor_agent::AuthMode::Auto).unwrap();Sourcepub fn delete(&self, host: &str, mode: AuthMode) -> Result<(), Error>
pub fn delete(&self, host: &str, mode: AuthMode) -> Result<(), Error>
Performs account deletion to a Vigor host.
§Examples
// assuming you already have an instance called "agent"
agent.delete("http://example.com/claims/", vigor_agent::AuthMode::Auto).unwrap();Sourcepub fn patch(
&self,
host: &str,
mode: AuthMode,
share_email: bool,
use_password: bool,
use_ed25519: bool,
) -> Result<(), Error>
pub fn patch( &self, host: &str, mode: AuthMode, share_email: bool, use_password: bool, use_ed25519: bool, ) -> Result<(), Error>
Performs account modification to a Vigor host.
This method expects three booleans after the host argument for whether email, password, and/or Ed25519 should be updated, respectively.
§Examples
// assuming you already have an instance called "agent"
agent.patch("http://example.com/claims/", vigor_agent::AuthMode::Auto, true, true, true).unwrap();