Skip to content

Add a borrowing cmsg api #2646

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

evan-brass
Copy link

What does this PR do

Adds a raw cmsg access api to the CmsgIterator. The goal is to bypass ControlMessageOwned which is marked non_exhaustive.

The SCTP messages I'm currently parsing hit the catchall ControlMessageOwned::Uknown, but my code would break if nix changes what the Unknown variant covers in the future, hence why I'm looking to access the messages raw.

I don't know enough about *nix to know if it's safe to return &'a references to the cmsg header and value so instead I borrowed from self, returning 1 control message at a time.

The safety of the unsafe blocks I believe are exactly the same as what I copied from ControlMessageOwned::decode_from.

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

This is mainly to support implementing custom control messages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant