-- |-- Module : Data.ASN1.Encoding-- License : BSD-style-- Maintainer : Vincent Hanquez <vincent@snarc.org>-- Stability : experimental-- Portability : unknown--
module Data.ASN1.Encoding
(
-- * generic class for decoding and encoding stream
ASN1Decoding(..)
, ASN1DecodingRepr(..)
, ASN1Encoding(..)
-- * strict bytestring version
, decodeASN1'
, decodeASN1Repr'
, encodeASN1'
) where
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as L
import Data.ASN1.Stream
import Data.ASN1.Types
import Data.ASN1.Error
-- | Describe an ASN1 decoding, that transform a bytestream into an asn1stream
class ASN1Decodinga where
-- | decode a lazy bytestring into an ASN1 streamdecodeASN1 :: a -> L.ByteString -> EitherASN1Error [ASN1]
-- | transition class.
class ASN1DecodingRepra where
-- | decode a lazy bytestring into an ASN1 streamdecodeASN1Repr :: a -> L.ByteString -> EitherASN1Error [ASN1Repr]
-- | Describe an ASN1 encoding, that transform an asn1stream into a bytestream
class ASN1Encodinga where
-- | encode a stream into a lazy bytestringencodeASN1 :: a -> [ASN1] -> L.ByteString-- | decode a strict bytestring into an ASN1 streamdecodeASN1' :: ASN1Decoding a =>a -> B.ByteString -> EitherASN1Error [ASN1]
decodeASN1'encodingbs = decodeASN1encoding$L.fromChunks [bs]
-- | decode a strict bytestring into an ASN1Repr streamdecodeASN1Repr' :: ASN1DecodingRepr a =>a -> B.ByteString -> EitherASN1Error [ASN1Repr]
decodeASN1Repr'encodingbs = decodeASN1Reprencoding$L.fromChunks [bs]
-- | encode a stream into a strict bytestringencodeASN1' :: ASN1Encoding a =>a -> [ASN1] -> B.ByteStringencodeASN1'encoding = B.concat.L.toChunks.encodeASN1encoding