| Copyright | (c) Viktor Dukhovni 2026 |
|---|---|
| License | BSD-3-Clause |
| Maintainer | ietf-dane@dukhovni.org |
| Stability | unstable |
| Safe Haskell | None |
| Language | GHC2024 |
Net.DNSBase.RData.SVCB.SPVSet
Description
The collection of service parameters carried in a single
SVCB or HTTPS record, keyed by SVCParamKey (one value
per key code, per RFC 9460). Construction is via the IsList
instance — fromList [SVCParamValue p1, ...]; enumeration via
toList returns the parameters in ascending key order, which
is also the canonical on-the-wire order.
Each key code is associated with a specific KnownSVCParamValue
type; the values are held inside the existential SVCParamValue
wrapper so a single set can mix heterogeneous parameter types.
spvLookup takes the parameter type as a type application
and returns the typed value when the matching key is present:
ghci> import qualified GHC.IsList as IL (fromList) ghci> spvset = IL.fromList @SPVSet [SVCParamValue (SPV_PORT 80), SVCParamValue SPV_NDALPN] ghci> spvset fromList @SPVSet [SVCParamValue SPV_NDALPN,SVCParamValue 80] ghci> spvLookup @SPV_ndalpn spvset Just SPV_NDALPN
The type application can be elided when a pattern match constrains the result type:
ghci> case spvLookup spvset of { Just (SPV_PORT p) -> p; _ -> 0 }
80Synopsis
- data SPVSet where
- pattern SPVMap :: IntMap SVCParamValue -> SPVSet
- spvLookup :: KnownSVCParamValue a => SPVSet -> Maybe a
- spvSetFromMonoList :: [SVCParamValue] -> SPVSet
Documentation
The set of service parameters in an SVCB or HTTPS record,
with at most one value per SVCParamKey. The Monoid
instance provides the empty set; the Semigroup instance is
left-biased on key collisions.
Bundled Patterns
| pattern SPVMap | One-sided pattern that exposes the underlying |
Fields
| |
Instances
| Presentable SPVSet Source # | |
Defined in Net.DNSBase.RData.SVCB.SPVSet Methods present :: SPVSet -> Builder -> Builder Source # presentLazy :: SPVSet -> ByteString -> ByteString Source # | |
| Monoid SPVSet Source # | |
| Semigroup SPVSet Source # | |
| IsList SPVSet Source # | Construction is via |
| Show SPVSet Source # | |
| Eq SPVSet Source # | |
| type Item SPVSet Source # | |
Defined in Net.DNSBase.RData.SVCB.SPVSet | |
spvLookup :: KnownSVCParamValue a => SPVSet -> Maybe a Source #
Look up the parameter at the key associated with type a,
returning a Just only when the stored value really is of type
a. A value of the same key code but held as OpaqueSPV
(because the typed instance was not registered when the record
was decoded) does not match — opaque values must be
retrieved through SPVMap.
spvSetFromMonoList :: [SVCParamValue] -> SPVSet Source #
Build an SPVSet from a list of SVCParamValues whose keys
are in strict monotone-increasing order (so also no
duplicates) — the precondition imposed by the underlying
fromDistinctAscList used to build the set. The "Mono"
is intended as a reminder of the precondition.
Used internally by the wire-form decoder, which validates
ascending keys during parsing; application code that cannot
guarantee the precondition should use fromList from the
IsList instance instead.