{-# OPTIONS_HADDOCK hide #-}
module Network.DNS.Decode.Internal (
decodeDNSHeader
, decodeDNSFlags
, decodeDomain
, decodeMailbox
, decodeResourceRecordAt
, decodeResourceRecord
) where
import Network.DNS.Decode.Parsers
import Network.DNS.Imports
import Network.DNS.StateBinary
import Network.DNS.Types.Internal
decodeDNSFlags :: ByteString -> Either DNSError DNSFlags
decodeDNSFlags :: ByteString -> Either DNSError DNSFlags
decodeDNSFlags bs :: ByteString
bs = (DNSFlags, PState) -> DNSFlags
forall a b. (a, b) -> a
fst ((DNSFlags, PState) -> DNSFlags)
-> Either DNSError (DNSFlags, PState) -> Either DNSError DNSFlags
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SGet DNSFlags -> ByteString -> Either DNSError (DNSFlags, PState)
forall a. SGet a -> ByteString -> Either DNSError (a, PState)
runSGet SGet DNSFlags
getDNSFlags ByteString
bs
decodeDNSHeader :: ByteString -> Either DNSError DNSHeader
bs :: ByteString
bs = (DNSHeader, PState) -> DNSHeader
forall a b. (a, b) -> a
fst ((DNSHeader, PState) -> DNSHeader)
-> Either DNSError (DNSHeader, PState) -> Either DNSError DNSHeader
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SGet DNSHeader -> ByteString -> Either DNSError (DNSHeader, PState)
forall a. SGet a -> ByteString -> Either DNSError (a, PState)
runSGet SGet DNSHeader
getHeader ByteString
bs
decodeDomain :: ByteString -> Either DNSError Domain
decodeDomain :: ByteString -> Either DNSError ByteString
decodeDomain bs :: ByteString
bs = (ByteString, PState) -> ByteString
forall a b. (a, b) -> a
fst ((ByteString, PState) -> ByteString)
-> Either DNSError (ByteString, PState)
-> Either DNSError ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SGet ByteString
-> ByteString -> Either DNSError (ByteString, PState)
forall a. SGet a -> ByteString -> Either DNSError (a, PState)
runSGet SGet ByteString
getDomain ByteString
bs
decodeMailbox :: ByteString -> Either DNSError Mailbox
decodeMailbox :: ByteString -> Either DNSError ByteString
decodeMailbox bs :: ByteString
bs = (ByteString, PState) -> ByteString
forall a b. (a, b) -> a
fst ((ByteString, PState) -> ByteString)
-> Either DNSError (ByteString, PState)
-> Either DNSError ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SGet ByteString
-> ByteString -> Either DNSError (ByteString, PState)
forall a. SGet a -> ByteString -> Either DNSError (a, PState)
runSGet SGet ByteString
getMailbox ByteString
bs
decodeResourceRecord :: ByteString -> Either DNSError ResourceRecord
decodeResourceRecord :: ByteString -> Either DNSError ResourceRecord
decodeResourceRecord bs :: ByteString
bs = (ResourceRecord, PState) -> ResourceRecord
forall a b. (a, b) -> a
fst ((ResourceRecord, PState) -> ResourceRecord)
-> Either DNSError (ResourceRecord, PState)
-> Either DNSError ResourceRecord
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SGet ResourceRecord
-> ByteString -> Either DNSError (ResourceRecord, PState)
forall a. SGet a -> ByteString -> Either DNSError (a, PState)
runSGet SGet ResourceRecord
getResourceRecord ByteString
bs
decodeResourceRecordAt :: Int64
-> ByteString
-> Either DNSError ResourceRecord
decodeResourceRecordAt :: Int64 -> ByteString -> Either DNSError ResourceRecord
decodeResourceRecordAt t :: Int64
t bs :: ByteString
bs = (ResourceRecord, PState) -> ResourceRecord
forall a b. (a, b) -> a
fst ((ResourceRecord, PState) -> ResourceRecord)
-> Either DNSError (ResourceRecord, PState)
-> Either DNSError ResourceRecord
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int64
-> SGet ResourceRecord
-> ByteString
-> Either DNSError (ResourceRecord, PState)
forall a.
Int64 -> SGet a -> ByteString -> Either DNSError (a, PState)
runSGetAt Int64
t SGet ResourceRecord
getResourceRecord ByteString
bs