[−][src]Function netlink_proto::new_connection
pub fn new_connection<T>(
protocol: Protocol
) -> Result<(Connection<T>, ConnectionHandle<T>, UnboundedReceiver<(NetlinkMessage<T>, SocketAddr)>)> where
T: Debug + PartialEq + Eq + Clone + NetlinkSerializable<T> + NetlinkDeserializable<T> + Unpin,
Create a new Netlink connection for the given Netlink protocol,
and returns a handle to that connection as well as a stream of
un-sollicited messages received by that connection (un-sollicited
here means messages that are not a response to a request made by
the Connection
). Connection<T>
wraps a Netlink socket and
implements the Netlink protocol.
T
is the type of netlink messages used for this protocol. For
instance, if you're using the AUDIT protocol with the
netlink-packet-audit
crate, T
will be
netlink_packet_audit::AuditMessage
. More generaly, T
is
anything that can be serialized and deserialized into a Netlink
message. See the netlink_packet_core
documentation for details
about the NetlinkSerializable
and NetlinkDeserializable
traits.
Most of the time, users will want to spawn the Connection
on an
async runtime, and use the handle to send messages.