This language feature is deprecated, but the lint for it is not
enabled by default. Enabling the lint and fixing all occurrences also
resolves some new Clippy lints. This does not affect the API or
behaviour of the code in any way.
This PR looks at all the error types and splits them into meaningful error
information, which will be available as enum variants, and internals, which
will be hidden away behind opaque structs. For the former case, we will
still use enums directly rather than have error kind enums. These will not
be non-exhaustive since they should really cover all possible cases and
exhaustive matching should work.
This is a breaking change.
This PR fixes TXT record data serialization for human-readable formats. TXT
record data is now serialized as a sequence of character strings. It also
deserializes from such a sequence. If supported by the format, it
alternatively deserializes from a string that is broken up into 255 octet
chunks if necessary.
It uses a newly added helper type base::charstr::DeserializeCharStrSeed that
deserializes character strings by appending them to an octets builder. Since
this may be useful for other cases, it has been made public.
This is a breaking change.
This PR redesigns the conversion of CharStr from and to text formats.
It distinguishes between three text formats: quoted and unquoted
representation format (i.e., what’s used in zonefiles) and a serialization
format which is an unquoted format with only backslash and non-printable
octets escaped. The latter will be used in serialization but also by default
for Display. This makes it reversible with the FromStr implementation but
avoids escaping white space. Methods for explicitly displaying in quoted and
unquoted representation format are provided.
Serialization works mostly as before but uses the serialization format
rather than the unquoted representation format in human-readable formats. It
still uses the raw octets in binary formats.
The PR adds proper documentation for all of it to the type.
This PR changes the rdata::Txt type to reject empty record data as invalid.
RFC 1035 states that the TXT-DATA is “One or more <character-string>s”. This
means that there will have to be at least the length octet of the first
character string.
The PR also adjusts the TxtBuilder to never return a empty data. Since this
requires being able to return an error in TxtBuilder:.finish, this is a
breaking change. While at it, the PR also adds more control over the created
character strings by making close_char_str public and adding a new
append_char_str method.
The PR also improves the documentation for the TXT record data types.
This PR fixes the Display implementation for the Txt record data type. It
now prints each character string separately and quoted. It uses the new
CharStr::display_quoted method that prints the content of a character string
quoted and with only necessary characters escaped.
This PR removes the Deref and DerefMut impls from types that aren’t smart
pointers and thus shouldn’t really have them according to the advise given
in the documentation.
Where appropriate, it adds len and is_empty methods. Additional methods
likely should be added later as well.
In particular:
o Removed impls of Deref and (if present) DerefMut for the following
types: CharStr, CharStrBuilder, DnameBuilder, Label, A, Aaaa, all
record types that wrap a domain name, Nsec3Salt, OwnerHash,
SearchList, ServerList. Where necessary, len and is_empty were added.
o IntoIterator for Label has a changed Self::Item.
This is a breaking change.
This commit adds a ?Sized trait bound to all types that exclusively wrap an
octets sequence. In the process, it also does some cleanup here and there to
improve consistency of the crate.
Specifically, it includes the following noteworthy changes:
o All types that wrap an octets sequence only allow unsized octets
sequence types. They all have an associated function from_slice to
create a reference to a value wrapping an (unsized) octets slice and
method for_slice that converts a &self into such a reference. Where
the latter already existed but returned a value wrapping a &[u8]
(e.g., Dname<_> and Message<_>, the return type has changed
accordingly.
o Removed CharStr::from_bytes. Use CharStr::from_octets instead.
o Message::from_octets now returns a new error type ShortMessage.
o Dropped Deref impls for Dname<_>, RelativeDname<_>.
o Renamed opt::KeyTag::new to opt::KeyTag::from_octets.
o Renamed rdata::Txt::try_from_slice to build_from_slice.
This commit swaps the traits and types defined in `base::octets` for their
equivalent in the `octseq` trait. These are mostly the same except that they
facilitate Generic Associated Types as stabilized in Rust 1.65. This results
in subtly changed trait bounds, though mostly these should be invisible to
the user.
One notable change is that `octseq` makes the error type of the
`OctetsBuilder` generic and uses `Infallible` for those types where
appending data will never fail (which, for most users, is all of them). It
provides methods for either case and we are mirroring these in `domain`.
While this means that converting you code to using the PR will require some
work, that work should mostly be removing unwraps – which is nice.
We’re using the opportunity to clean up a few more things that have crept
into the code over time. A list of which will be added here:
* The range, slice, and split methods on the domain name types have
changed. They have been merge into a single method taking ranges – except
for those on `Dname` that require type changes. The split methods now
take references and don’t change `self` anymore. This is somewhat
required by the limitations imposed by the new `Octets` trait but feels
better, anyway.
* The `Parse`, `Compose`, and `Scan` traits have been demoted to mere
extension traits for foreign types (primarily the built-in integers, so
that you can do things like `u16::parse`). All other types now simply have
methods matching the patterns. Where generics are necessary, dedicated
traits have been added. E.g., there now are `ParseRecordData` and
`ComposeRecordData` traits that are implemented by all record data types.
* Composing of record data and options has been switched to a scheme where
the size is predetermined whenever possible instead of composing the data
and then updating the length after. Since this is not possible for record
data that uses compressed names when compression is actually in use, the
old scheme is still used in this particular case.
This commit completely redesigns zone file parsing. The primary change is to
convert the scanner into a trait in order to allow multiple zone parser
implementations for different sources and purposes. A number of changes had
to be made in order to make this possible.
The commit also contains an initial implementation of a scanner that modifies
data in-place and can thus returned parsed data with only a minimal amount
of additional allocations. While working, this scanner is more a
proof-of-concept at this point to ensure that the API design is sound.
This commit is based on ideas and code proposed by @not-my-profile in #106.
This commit increases the minimal supported Rust version to 1.59.0.
This makes it possible to impl OctetsBuilder for Cow<[u8]> and other
types that can only append at the price of explicitely requiring AsRef<[u8]>
and AsMut<[u8]> where needed. Unfortunately, this means lots of code
changes but hopefully, these should not cause too much havoc with code
using the crate.
The unstable doc_cfg feature[0] makes rustdoc generate pretty notes for
APIs that are annotated to require a certain feature flag.
This commit adds these annotations and enables the unstable feature
for docs.rs builds (which already use nightly[1]).
To build the documentation locally with this feature use:
RUSTDOCFLAGS='--cfg docsrs' cargo +nightly doc --no-deps --all-features
[0]: https://doc.rust-lang.org/unstable-book/language-features/doc-cfg.html
[1]: https://docs.rs/about/builds