Skip to main content

Helper

Trait Helper 

Source
pub trait Helper: Send + Sync {
    // Required methods
    fn fill(&self, query: &Query) -> Result<Option<Credentials>, HelperError>;
    fn approve(
        &self,
        query: &Query,
        creds: &Credentials,
    ) -> Result<(), HelperError>;
    fn reject(
        &self,
        query: &Query,
        creds: &Credentials,
    ) -> Result<(), HelperError>;
}
Expand description

Resolve credentials for a given query, and report success/failure back so the helper can persist or invalidate its state.

Send + Sync so a single helper can be shared across the async transfer queue. Implementations that aren’t naturally thread-safe (e.g. wrap a Cell) should layer their own synchronization.

Required Methods§

Source

fn fill(&self, query: &Query) -> Result<Option<Credentials>, HelperError>

Try to fetch credentials for query.

Ok(None) means “I don’t know”; the chain should consult the next helper. Err is a hard failure (e.g. helper subprocess crashed) and aborts the chain.

Source

fn approve(&self, query: &Query, creds: &Credentials) -> Result<(), HelperError>

Tell the helper that creds worked for query.

Helpers that can persist (git credential, OS keychain via git credential) should store the pair; pure caches use this to populate themselves.

Source

fn reject(&self, query: &Query, creds: &Credentials) -> Result<(), HelperError>

Tell the helper that creds did not work for query.

Helpers should drop the credentials so we don’t loop on stale entries.

Implementors§