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

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 }
80
Synopsis

Documentation

data SPVSet where Source #

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 IntMap for traversal or low-level inspection. The values are kept in the existential SVCParamValue wrapper, so any concrete parameter may be either typed (a KnownSVCParamValue instance) or OpaqueSPV. For typed lookups by parameter type use spvLookup instead.

Fields

Instances

Instances details
Presentable SPVSet Source # 
Instance details

Defined in Net.DNSBase.RData.SVCB.SPVSet

Monoid SPVSet Source # 
Instance details

Defined in Net.DNSBase.RData.SVCB.SPVSet

Semigroup SPVSet Source # 
Instance details

Defined in Net.DNSBase.RData.SVCB.SPVSet

IsList SPVSet Source #

Construction is via fromList, and enumeration is via toList.

Instance details

Defined in Net.DNSBase.RData.SVCB.SPVSet

Associated Types

type Item SPVSet 
Instance details

Defined in Net.DNSBase.RData.SVCB.SPVSet

Show SPVSet Source # 
Instance details

Defined in Net.DNSBase.RData.SVCB.SPVSet

Eq SPVSet Source # 
Instance details

Defined in Net.DNSBase.RData.SVCB.SPVSet

Methods

(==) :: SPVSet -> SPVSet -> Bool #

(/=) :: SPVSet -> SPVSet -> Bool #

type Item SPVSet Source # 
Instance details

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.