[][src]Struct harlequinn::HqEndpoint

pub struct HqEndpoint { /* fields omitted */ }

A harlequinn client or server endpoint.

Methods

impl HqEndpoint[src]

pub fn new_client(protocol: &str) -> Self[src]

Creates a new client endpoint.

Doesn't listen for incoming connections, use connect to start a connection to a server.

pub fn new_server(
    protocol: &str,
    socket_addr: SocketAddr,
    certificate: Certificate,
    private_key: PrivateKey
) -> Self
[src]

Creates a new server endpoint.

Listens for incoming connections.

pub fn connect<S: ToString>(
    &mut self,
    server_addr: SocketAddr,
    server_name: S,
    certificate: Certificate
) -> PeerId
[src]

Initiate a connection to a server endpoint.

Raises ConnectionFailed on failure, and ConnectionRequested on success.

pub fn disconnect(&mut self, peer_id: PeerId, reason: String)[src]

Disconnects a peer, ending the connection.

reason is not preserved intact, and will be mangled on the other side, but can be used to provide human-readable reasons.

pub fn accept(&mut self, peer_id: PeerId)[src]

Accepts a pending connection.

pub fn reject(&mut self, peer_id: PeerId)[src]

Rejects a pending connection.

pub fn send_datagram(&mut self, peer_id: PeerId, bytes: Bytes)[src]

Send an unreliable datagram to a peer.

If the peer is taking too long to respond to messages, this may disconnect the peer.

pub fn send_message(
    &mut self,
    peer_id: PeerId,
    bytes: Bytes,
    order: MessageOrder
)
[src]

Send a reliable message over the main stream to a peer.

Messages with ordered set to true will arrive in order at the peer.

If the peer is taking too long to respond to messages, this may disconnect the peer.

pub fn poll_events(&mut self, events: &mut Vec<EndpointEvent>)[src]

Polls for events and stores them in the given events buffer.

This must be called frequently, or the endpoint will run out of space in the events channel and stall.

Trait Implementations

impl Drop for HqEndpoint[src]

Auto Trait Implementations

Blanket Implementations

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 = !

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.

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

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

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

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,