[][src]Module neli::socket

This module provides code that glues all of the other modules together and allows message send and receive operations.

Important methods

  • NlSocket::send and NlSocket::recv methods are meant to be the most low level calls. They essentially do what the C system calls send and recv do with very little abstraction.
  • NlSocketHandle::send and NlSocketHandle::recv methods are meant to provide an interface that is more idiomatic for the library. The are able to operate on any structure wrapped in an Nlmsghdr struct that implements the Nl trait.
  • NlSocketHandle::iter provides a loop based iteration through messages that are received in a stream over the socket.

Features

The async feature exposed by cargo allows the socket to use Rust's tokio for async IO.

Additional methods

There are methods for blocking and non-blocking, resolving generic netlink multicast group IDs, and other convenience functions so see if your use case is supported. If it isn't, please open a Github issue and submit a feature request.

Design decisions

The buffer allocated in the NlSocketHandle structure should be allocated on the heap. This is intentional as a buffer that large could be a problem on the stack. Big thanks to @vorner for the suggestion on how to minimize allocations.

Modules

tokio

Tokio-specific features for neli

Structs

NlSocket

Low level access to a netlink socket.

NlSocketHandle

Higher level handle for socket operations.