Struct genetlink::GenetlinkHandle [−][src]
pub struct GenetlinkHandle { /* fields omitted */ }Expand description
The generic netlink connection handle
The handle is used to send messages to the connection. It also resolves the family id automatically before sending messages.
Family id resolving
There is a resolver with cache inside each connection. When you send generic netlink message, the handle resolves and fills the family id into the message.
Since the resolver is created in new_connection(),
the cache state wouldn’t share between different connections.
P.s. The cloned handles use the same connection with the original handle. So, they share the same cache state.
Detailed process of sending generic messages
- Check if the message’s family id is resolved. If yes, jump to step 6.
- Query the family id using the builtin resolver.
- If the id is in the cache, returning the id in the cache and skip step 4.
- The resolver sends
CTRL_CMD_GETFAMILYrequest to get the id and records it in the cache. - fill the family id using
GenlMessage::set_resolved_family_id(). - Serialize the payload to
RawGenlMessage. - Send it through the connection.
- The family id filled into
message_typefield inNetlinkMessage::finalize().
- The family id filled into
- In the response stream, deserialize the payload back to
GenlMessage<F>.
Implementations
Resolve the family id of the given GenlFamily.
Clear the resolver’s fanily id cache
pub async fn request<F>(
&mut self,
message: NetlinkMessage<GenlMessage<F>>
) -> Result<impl Stream<Item = Result<NetlinkMessage<GenlMessage<F>>, DecodeError>>, GenetlinkError> where
F: GenlFamily + Emitable + ParseableParametrized<[u8], GenlHeader> + Debug,
pub async fn request<F>(
&mut self,
message: NetlinkMessage<GenlMessage<F>>
) -> Result<impl Stream<Item = Result<NetlinkMessage<GenlMessage<F>>, DecodeError>>, GenetlinkError> where
F: GenlFamily + Emitable + ParseableParametrized<[u8], GenlHeader> + Debug,
Send the generic netlink message and get the response stream
The function resolves the family id before sending the request. If the resolving process is failed, the function would return an error.
pub fn send_request<F>(
&mut self,
message: NetlinkMessage<GenlMessage<F>>
) -> Result<impl Stream<Item = Result<NetlinkMessage<GenlMessage<F>>, DecodeError>>, GenetlinkError> where
F: GenlFamily + Emitable + ParseableParametrized<[u8], GenlHeader> + Debug,
pub fn send_request<F>(
&mut self,
message: NetlinkMessage<GenlMessage<F>>
) -> Result<impl Stream<Item = Result<NetlinkMessage<GenlMessage<F>>, DecodeError>>, GenetlinkError> where
F: GenlFamily + Emitable + ParseableParametrized<[u8], GenlHeader> + Debug,
Send the request without resolving family id
This function is identical to request() but it doesn’t
resolve the family id for you.
pub async fn notify<F>(
&mut self,
message: NetlinkMessage<GenlMessage<F>>
) -> Result<(), GenetlinkError> where
F: GenlFamily + Emitable + ParseableParametrized<[u8], GenlHeader> + Debug,
pub async fn notify<F>(
&mut self,
message: NetlinkMessage<GenlMessage<F>>
) -> Result<(), GenetlinkError> where
F: GenlFamily + Emitable + ParseableParametrized<[u8], GenlHeader> + Debug,
Send the generic netlink message without returning the response stream
pub fn send_notify<F>(
&mut self,
message: NetlinkMessage<GenlMessage<F>>
) -> Result<(), GenetlinkError> where
F: GenlFamily + Emitable + ParseableParametrized<[u8], GenlHeader> + Debug,
pub fn send_notify<F>(
&mut self,
message: NetlinkMessage<GenlMessage<F>>
) -> Result<(), GenetlinkError> where
F: GenlFamily + Emitable + ParseableParametrized<[u8], GenlHeader> + Debug,
Send the notify without resolving family id
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for GenetlinkHandle
impl Send for GenetlinkHandle
impl Sync for GenetlinkHandle
impl Unpin for GenetlinkHandle
impl !UnwindSafe for GenetlinkHandle
Blanket Implementations
Mutably borrows from an owned value. Read more
