-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copying Rtmsg
value
#248
Comments
Maybe I'm just not proficient with rust enough yet tho :( |
Hi @pseusys, have you tried |
Yes. I doublechecked that: it is implemented, but only in the latest releases (0.7.0), that are still release candidates. In the latest stable release, there is no Clone trait available. |
I see your problem after digging into this a little bit deeper. Here's what I would suggest as a workaround. It's not ergonomic, but I think it should work: if let NlPayload::Payload(recv_payload) = header.nl_payload {
if recv_payload.rtm_table == table_const {
let rm_msg = Nlmsghdr::new(None, Rtm::Delroute, NlmFFlags::new(&[NlmF::Request]), None, None, /* Reconstruct an NlPayload::(Rtmsg::new()) here. All of the fields are able to be copied and are public except for the attributes which can be borrowed. That should be sufficient for sending the message. /*);
sender_socket.send(rm_msg).unwrap();
table_data.push(recv_payload); // The above will not consume the data structure, just borrow it, so then you can move ownership to the vector.
}
} Let me know if you need any more help with this. |
I will come back to it again once 0.7.0 is released and try different solutions. |
I would like to implement something close to
ip route save
command, store all the contents of a routing table and clear it.For that purpose I have implemented a simple function:
For now I am struggling with copying received
Rtmsg
instances.Basically I can not store them in an array and also use for removing from the table call at the same time, since they do not implement
Copy
trait.How could I possibly save the message instance for future use and also remove it from the table?
Is there a way to copy it?
The text was updated successfully, but these errors were encountered: