pub struct NetApp {
    pub version_tag: [u8; 16],
    pub netid: Key,
    pub id: PublicKey,
    pub privkey: SecretKey,
    /* private fields */
}
Expand description

NetApp is the main class that handles incoming and outgoing connections.

NetApp can be used in a stand-alone fashion or together with a peering strategy. If using it alone, you will want to set on_connect and on_disconnect events in order to manage information about the current peer list.

It is generally not necessary to use NetApp stand-alone, as the provided full mesh and RPS peering strategies take care of the most common use cases.

Fields§

§version_tag: [u8; 16]

Version tag, 8 bytes for netapp version, 8 bytes for app version

§netid: Key

Network secret key

§id: PublicKey

Our peer ID

§privkey: SecretKey

Private key associated with our peer ID

Implementations§

Creates a new instance of NetApp, which can serve either as a full p2p node, or just as a passive client. To upgrade to a full p2p node, spawn a listener using .listen()

Our Peer ID is the public key associated to the secret key given here.

Set the handler to be called when a new connection (incoming or outgoing) has been successfully established. Do not set this if using a peering strategy, as the peering strategy will need to set this itself.

Set the handler to be called when an existing connection (incoming or outgoing) has been closed by either party. Do not set this if using a peering strategy, as the peering strategy will need to set this itself.

Create a new endpoint with path path, that handles messages of type M. H is the type of the object that should handle requests to this endpoint on the local node. If you don’t want to handle request on the local node (e.g. if this node is only a client in the network), define the type H to be (). This function will panic if the endpoint has already been created.

Main listening process for our app. This future runs during the whole run time of our application. If this is not called, the NetApp instance remains a passive client.

Drop all endpoint handlers, as well as handlers for connection/disconnection events. (This disables the peering strategy)

Use this when terminating to break reference cycles

Attempt to connect to a peer, given by its ip:port and its public key. The public key will be checked during the secret handshake process. This function returns once the connection has been established and a successfull handshake was made. At this point we can send messages to the other node with Netapp::request

Close the outgoing connection we have to a node specified by its public key, if such a connection is currently open.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Attaches the current Context to this type, returning a WithContext wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more