[][src]Struct psk_client::builder::PskClientBuilder

pub struct PskClientBuilder<'a, H: ToSocketAddrs> { /* fields omitted */ }

The builder for a PSK client, somewhat simplifies creating a new PSK client and makes it more ergonomic.

Implementations

impl<'a, H: ToSocketAddrs> PskClientBuilder<'a, H>[src]

pub fn new(host: H) -> Self[src]

Create a new PskClientBuilder with the default cipher list, a None identity and an empty key.

pub fn build(self) -> Result<PskClient, PskClientError>[src]

Returns a new PskClient which can be used to

use psk_client::PskClient;
use std::io::Write;

if let Ok(client) = PskClient::builder("127.0.0.1:4433")
    .identity("some-client")
    .key("1A2B3C4D")
    .build()
{
    if let Ok(mut connection) = client.connect() {
        connection.write_all(b"oing").unwrap();
    }
}

pub fn use_fips(mut self: Self) -> Self[src]

Tries to enable FIPS for this client session, requires that OpenSSL has been compiled with FIPS enabled. Will silently fail if FIPS cannot be enabled.

use psk_client::PskClient;
let builder = PskClient::builder("127.0.0.1:4433")
    .use_fips();

pub fn require_fips(mut self: Self) -> Self[src]

Tries to enable FIPS for this client session, requires that OpenSSL has been compiled with FIPS enabled. Will return an error on client build if FIPS cannot be enabled.

use psk_client::PskClient;
let builder = PskClient::builder("127.0.0.1:4433")
    .require_fips();

#[must_use]pub fn identity<S: Into<String>>(mut self: Self, identity: S) -> Self[src]

Sets the identity to use for this session. This is required.

use psk_client::PskClient;
let builder = PskClient::builder("127.0.0.1:4433")
    .identity("some-client");

pub fn identity_from<R: Read>(
    self,
    mut reader: R
) -> Result<Self, PskClientError>
[src]

Sets the identity to use for this session, taking the identity from an object implementing Read

use psk_client::PskClient;
use psk_client::error::PskClientError;
use std::io::Cursor;

// Create a dummy file
let file = Cursor::new(b"some-identity");

let builder = PskClient::builder("127.0.0.1:4433")
    .identity_from(file)
    .unwrap();

#[must_use]pub fn key<S: Into<Vec<u8>>>(mut self: Self, key: S) -> Self[src]

Sets the key to use for this session. Must be valid hex. This is required.

use psk_client::PskClient;
let builder = PskClient::builder("127.0.0.1:4433")
    .key("1A2B3C4D");

pub fn key_from<R: Read>(self, mut reader: R) -> Result<Self, PskClientError>[src]

Sets the key to sue for this session, taking the value from an object which implements Read. Must be valid hex. It will also cleanup non alphanumeric characters to special sequences (like new lines, trailing whitespace) are not included.

use psk_client::PskClient;
use psk_client::error::PskClientError;
use std::io::Cursor;

// Create a dummy file
let file = Cursor::new(b"a1b2c3d4\n");

let builder = PskClient::builder("127.0.0.1:4433")
    .key_from(file)
    .unwrap();

pub fn cipher(mut self: Self, cipher: &'a str) -> Self[src]

Adds a given cipher to the list of ciphers to send to the server

use psk_client::PskClient;
let builder = PskClient::builder("127.0.0.1:4433")
    .cipher("PSK-AES256-CBC-SHA");

pub fn reset_ciphers(mut self: Self) -> Self[src]

Clears the current list of ciphers, which are initialised with a default PSK set.

use psk_client::PskClient;
let builder = PskClient::builder("127.0.0.1:4433")
    .reset_ciphers();

Trait Implementations

impl<'a, H: Clone + ToSocketAddrs> Clone for PskClientBuilder<'a, H>[src]

impl<'a, H: Debug + ToSocketAddrs> Debug for PskClientBuilder<'a, H>[src]

impl<'a, H: Default + ToSocketAddrs> Default for PskClientBuilder<'a, H>[src]

impl<'a, H: PartialEq + ToSocketAddrs> PartialEq<PskClientBuilder<'a, H>> for PskClientBuilder<'a, H>[src]

impl<'a, H: ToSocketAddrs> StructuralPartialEq for PskClientBuilder<'a, H>[src]

Auto Trait Implementations

impl<'a, H> RefUnwindSafe for PskClientBuilder<'a, H> where
    H: RefUnwindSafe
[src]

impl<'a, H> Send for PskClientBuilder<'a, H> where
    H: Send
[src]

impl<'a, H> Sync for PskClientBuilder<'a, H> where
    H: Sync
[src]

impl<'a, H> Unpin for PskClientBuilder<'a, H> where
    H: Unpin
[src]

impl<'a, H> UnwindSafe for PskClientBuilder<'a, H> where
    H: UnwindSafe
[src]

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.