dnsbase
Copyright(c) Viktor Dukhovni 2026
LicenseBSD-3-Clause
Maintainerietf-dane@dukhovni.org
Stabilityunstable
Safe HaskellNone
LanguageGHC2024

Net.DNSBase.Encode.Metric

Description

SizedBuilder is a Builder paired with its byte length, accumulated as the builder is assembled. Used inside RR-data encoders when an outer length-prefixed field needs the encoded value's length up front (RDLENGTH and the 16-bit length prefixes that introduce SVCB option values, EDNS option values, and similar). The mb* converters wrap the corresponding low-level builders so their byte-cost is tracked.

Synopsis

Documentation

data SizedBuilder Source #

Monoidal wrapper over Builder monoid that internally records the total length of the Builder output and maintains a flag for post-hoc error checking

Instances

Instances details
Monoid SizedBuilder Source # 
Instance details

Defined in Net.DNSBase.Encode.Internal.Metric

Semigroup SizedBuilder Source #

The semigroup operation is strict in all the elements of the tuple.

Instance details

Defined in Net.DNSBase.Encode.Internal.Metric

pattern SizedBuilder :: Int -> Builder -> SizedBuilder Source #

Extract length and builder when valid.

mbErr :: SizedBuilder Source #

SizedBuilder representing an unspecified error, probably one of the inputs was too long.

mbWord8 :: Word8 -> SizedBuilder Source #

Encode an unsigned 8-bit number.

mbWord16 :: Word16 -> SizedBuilder Source #

Encode an unsigned 16-bit number in network byte order.

mbWord32 :: Word32 -> SizedBuilder Source #

Encode an unsigned 32-bit number in network byte order.

mbWord64 :: Word64 -> SizedBuilder Source #

Encode an unsigned 64-bit number in network byte order.

mbByteString :: ByteString -> SizedBuilder Source #

Encode a ByteString of up to approximately 65535 bytes. In practice the limit is smaller since the entire DNS packet has a 16-bit length limit.

mbByteStringLen8 :: ByteString -> SizedBuilder Source #

Encode a length-tagged ByteString of up to 255 bytes.

mbByteStringLen16 :: ByteString -> SizedBuilder Source #

Encode a length-tagged ByteString of up to approximately 65535 bytes. In practice the limit is smaller since the entire DNS packet has a 16-bit length limit.

mbShortByteString :: ShortByteString -> SizedBuilder Source #

Encode a ShortByteString of up to approximately 65535 bytes. In practice the limit is smaller since the entire DNS packet has a 16-bit length limit.

mbShortByteStringLen8 :: ShortByteString -> SizedBuilder Source #

Encode a ShortByteString of up to 255 bytes, preceded by its length.

mbShortByteStringLen16 :: ShortByteString -> SizedBuilder Source #

Encode a length-tagged ByteString of up to approximately 65535 bytes. In practice the limit is smaller since the entire DNS packet has a 16-bit length limit.

mbIPv4 :: IPv4 -> SizedBuilder Source #

Encode an IPv4 address

mbIPv6 :: IPv6 -> SizedBuilder Source #

Encode an IPv4 address