Vigor

Struct Vigor 

Source
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: ConfigSchema

Configuration structure.

§path: PathBuf

Path to configuration file.

Implementations§

Source§

impl Vigor

Source

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

Reads configuration from disk. Does not check to see if path to configuration file exists.

Source

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

Writes configuration to disk.

Source

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.

Source

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();
Source

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();
Source

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();
Source

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();
Source

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();

Trait Implementations§

Source§

impl Debug for Vigor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Vigor

§

impl RefUnwindSafe for Vigor

§

impl Send for Vigor

§

impl Sync for Vigor

§

impl Unpin for Vigor

§

impl UnwindSafe for Vigor

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