[][src]Struct cjdns_keys::CJDNSKeysApi

pub struct CJDNSKeysApi { /* fields omitted */ }

Type that encapsulates some crate functions making it safer for its users to work with randomly created keys.

The struct initialization ensures thread-safety in runtime. If you don't need to work with randomly created keys, you can use appropriate key types directly.

Implementations

impl CJDNSKeysApi[src]

pub fn new() -> Result<Self, ()>[src]

Initialization function, which guarantees on success that it will be safe to call methods which use "randomize" logic (i.e. key_pair, gen_private_key).

If you want to work with randomly created cjdns keys, it's recommended to first initialize CJDNSKeysApi. For example:

use cjdns_keys::CJDNSKeysApi;

let keys_api = CJDNSKeysApi::new().expect("thread-safe initialization failed");
// valid random key pair
let keys = keys_api.key_pair();

pub fn key_pair(&self) -> CJDNSKeys[src]

Convenience method that generates safely valid key "pair". Returns CJDNSKeys struct with corresponding keys as its fields.

CJDNSKeys doc states presence of a contract between ip6 and public key. The contract is met within the method.

pub fn gen_private_key(&self) -> CJDNSPrivateKey[src]

Safely generates private key.

Considered safe, because the method takes immutable reference of the successfully initialized api type instance.

Auto Trait Implementations

impl RefUnwindSafe for CJDNSKeysApi

impl Send for CJDNSKeysApi

impl Sync for CJDNSKeysApi

impl Unpin for CJDNSKeysApi

impl UnwindSafe for CJDNSKeysApi

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.