[][src]Struct quic_p2p::QuicP2p

pub struct QuicP2p { /* fields omitted */ }

Main QuicP2p instance to communicate with QuicP2p

Implementations

impl QuicP2p[src]

pub fn new(event_tx: EventSenders) -> R<QuicP2p>[src]

Construct QuicP2p with the default config.

pub fn with_config(
    event_tx: EventSenders,
    cfg: Option<Config>,
    bootstrap_nodes: VecDeque<SocketAddr>,
    use_bootstrap_nodes_exclusively: bool
) -> R<QuicP2p>
[src]

Construct QuicP2p with supplied parameters, ready to be used. If config is not specified it'll call Config::read_or_construct_default()

bootstrap_nodes: takes bootstrap nodes from the user.

Either use these exclusively or in addition to the ones read from bootstrap cache file if such a file exists

pub fn bootstrap(&mut self)[src]

Bootstrap to the network.

Bootstrap concept is different from "connect" in several ways: bootstrap() will try to connect to all peers which are specified in the config (hard_coded_contacts) or were previously cached. If one bootstrap connection succeeds, all other connections will be dropped.

In case of success Event::BootstrapedTo will be fired. On error quic-p2p will fire Event::BootstrapFailure.

pub fn connect_to(&mut self, node_addr: SocketAddr)[src]

Connect to the given peer. This will error out if the peer is already in the process of being connected to OR for any other connection failure reasons.

pub fn disconnect_from(&mut self, peer_addr: SocketAddr)[src]

Disconnect from the given peer

pub fn send(&mut self, peer: Peer, msg: Bytes, token: Token)[src]

Send message to peer.

If the peer is not connected, it will attempt to connect to it first and then send the message. This can be called multiple times while the peer is still being connected to - all the sends will be buffered until the peer is connected to.

token is supplied by the user code and will be returned with the message to help identify the context, for successful or unsuccessful sends.

pub fn our_connection_info(&mut self) -> R<SocketAddr>[src]

Get our connection info to give to others for them to connect to us

Will use hard coded contacts to ask for our endpoint. If no contact is given then we'll simply build our connection info by querying the underlying bound socket for our address. Note that if such an obtained address is of unspecified category we will ignore that as such an address cannot be reached and hence not useful.

pub fn bootstrap_cache(&mut self) -> R<Vec<SocketAddr>>[src]

Retrieves current node bootstrap cache.

pub fn is_hard_coded_contact(&self, node_addr: &SocketAddr) -> bool[src]

Checks whether the given contact is hard-coded.

pub fn config(&self) -> Config[src]

Returns a copy of the Config used to create this QuicP2p.

Auto Trait Implementations

impl !RefUnwindSafe for QuicP2p

impl Send for QuicP2p

impl Sync for QuicP2p

impl Unpin for QuicP2p

impl !UnwindSafe for QuicP2p

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> Instrument 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.

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