[][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.

Methods

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

#[must_use]
pub fn identity<S: Into<String>>(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");

#[must_use]
pub fn key<K: AsRef<[u8]>>(self, key: K) -> Self
[src]

Sets the key to use for this session. Must be valid hex, if not this function will panic. This is required.

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

pub fn cipher(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(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: PartialEq + ToSocketAddrs> PartialEq<PskClientBuilder<'a, H>> for PskClientBuilder<'a, H>[src]

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

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

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

Auto Trait Implementations

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

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

Blanket Implementations

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

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