Safe Haskell | None |
---|---|
Language | Haskell2010 |
Newtype for manipulating length-prefixed strings.
This type is for UTF-8 Text
that you intend to write out to a length-prefixed
bytestring. The size of the length field is static. You essentially have to
decide the maximum bytesize of the string on creation.
Synopsis
- newtype PascalText (n :: Nat) = PascalText {
- unPascalText :: Text
- encodePascalText :: forall n. KnownNat n => PascalText n -> Maybe ByteString
- encodeToSizedBE :: (Integral a, Bits a) => Int -> a -> Maybe ByteString
- i2be :: (Integral a, Bits a) => a -> ByteString
Documentation
newtype PascalText (n :: Nat) Source #
Instances
KnownNat n => BinRep (PascalText n) Source # | |
Defined in StreamPatch.Patch.Binary.PascalText toBinRep :: PascalText n -> Either String ByteString Source # |
encodePascalText :: forall n. KnownNat n => PascalText n -> Maybe ByteString Source #
encodeToSizedBE :: (Integral a, Bits a) => Int -> a -> Maybe ByteString Source #
i2be :: (Integral a, Bits a) => a -> ByteString Source #
Re-encode an Integer
to a little-endian integer stored as a
ByteString
using the fewest bytes needed to represent it.
adapated from crypto-api 0.13.3, Crypto.Util.i2bs_unsized