-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
Introduce a new base
module
#474
base: main
Are you sure you want to change the base?
Conversation
It implements 'Hash' for the provided integer types.
|
||
//--- Impls for 'Option<T>' | ||
|
||
impl<T: ParseQuestion> ParseQuestion for Option<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this one. Is this to say that the question might not match but it will still fail if no questions are given?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, it needs docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see it just maps Some
over the result? When is None
returned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None
is returned if the message was correctly formatted, but no matching T
was found in it (e.g. if T
is specifically an A record).
} | ||
|
||
/// A type that can be constructed by parsing zero or more DNS questions. | ||
pub trait ParseQuestions: Sized { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love a different name for this to differentiate with ParseQuestion
. Maybe ParseManyQuestions
.
This ended up collecting a lot of small changes as I tried to get things to compile. - All the bytes parsing/building traits have been moved to 'wire'. - The 'wire::ints' module replaces 'U16' and 'U32' from 'zerocopy'. - '{Parse,Split}BytesByRef' now support parsing from '&mut'. - Every derive macro is documented under a re-export in 'wire'. The remaining contents of 'new_base::{build, parse}' might get moved into a shared 'message' module at some point. We'll see.
Instead of passing the input selection as a range for parsing, the whole message is cut (using 'Message::slice_to()') and only the start is indicated. This ensures that we never cross the end of the range. It also implicitly dictates that compressed names are not allowed to reference future locations in messages. In addition, both the parsing traits now use offsets into the message _contents_ rather than the whole message. They can avoid 'as_bytes()' everywhere and have better guarantees of success. It also ensures the message header can never be selected for parsing.
This has already caught a missing commit (for 'Question').
This introduces a
new_base
module as a potential candidate for replacingbase
. While it has a similar structure (although much is left to be filled out), it has three distinguishing features:It builds the foundation for a
derive
-based interface for easily and efficiently parsing (and possibly building) DNS messages.It introduces
RevName
, a more efficient type for domain names (where labels are stored in reverse order).There's a lot more work to be done:
Note: this is a new version of #469 with a less problematic branch name.