Skip to main content

TlsSender

Struct TlsSender 

Source
pub struct TlsSender { /* private fields */ }
Expand description

Sends events over one TLS connection to a TAK Server streaming input, for example takserver:8089. The handshake (including the client certificate) completes in connect, so a wrong CA or a rejected certificate fails there, not on the first event.

use uas_cot::net::{TlsConfig, TlsSender};

let tls = TlsConfig::from_pem_files("ca.pem", "user.pem", "user.key")?;
let mut tak = TlsSender::connect("takserver.example:8089", &tls)?;
tak.send(&uas_cot::Event::new("test-1", "a-f-G", uas_cot::now_us(), 60))?;

Implementations§

Source§

impl TlsSender

Source

pub fn connect(addr: &str, config: &TlsConfig) -> Result<Self>

Connects to addr (host:port) and checks the server certificate against host.

Source

pub fn connect_named( addr: impl ToSocketAddrs, server_name: &str, config: &TlsConfig, ) -> Result<Self>

Connects to addr and checks the server certificate against server_name (a DNS name or an IP address), for a server you reach by one address and whose certificate names another.

Source

pub fn send(&mut self, event: &Event) -> Result<()>

Sends one event and flushes it to the socket.

Source

pub fn stream_mut(&mut self) -> &mut StreamOwned<ClientConnection, TcpStream> ⓘ

The TLS stream, for reading what the server sends back (TAK Server streams other clients’ events to a connected client).

Source

pub fn close(self) -> Result<()>

Sends a TLS close_notify and flushes it, so the server sees a clean end of stream rather than a truncated one.

Trait Implementations§

Source§

impl Debug for TlsSender

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.