| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Registry.Json.Scratch
Description
A growable byte buffer that one read writes front to back, rewinds in place, and copies each finished value out of. It writes the bytes aeson writes for strings and integers without building them first.
Synopsis
- data Scratch st
- newScratch :: Int -> ST st (Scratch st)
- scratchCursor :: Scratch st -> ST st Int
- rewindTo :: Scratch st -> Int -> ST st ()
- scratchBuffer :: Scratch st -> ST st (MutableByteArray st)
- reserve :: Scratch st -> Int -> (MutableByteArray st -> Int -> ST st a) -> ST st a
- putByte :: Scratch st -> Word8 -> ST st ()
- putVarint :: Scratch st -> Int -> ST st ()
- putEncodedText :: Scratch st -> (Int -> Int) -> Text -> ST st ()
- putPlainBytes :: Scratch st -> ByteString -> ST st ()
- putRawBytes :: Scratch st -> ByteString -> ST st ()
- putDecimal :: Scratch st -> Int -> ST st ()
- putAt :: Scratch st -> Int -> (MutableByteArray st -> Int -> ST st Int) -> ST st ()
- copyOut :: Scratch st -> Int -> Int -> ST st ByteArray
- decimalLength :: Int -> Int
Documentation
scratchBuffer :: Scratch st -> ST st (MutableByteArray st) Source #
The buffer as it stands. Any later write that needs room may replace it.
reserve :: Scratch st -> Int -> (MutableByteArray st -> Int -> ST st a) -> ST st a Source #
The buffer with room for the given bytes past the cursor, and the cursor.
putVarint :: Scratch st -> Int -> ST st () Source #
Write a non-negative integer seven bits at a time, low bits first.
putEncodedText :: Scratch st -> (Int -> Int) -> Text -> ST st () Source #
Write the varint a header makes of a string's encoded length, then the bytes aeson writes for the string, quotes included.
putPlainBytes :: Scratch st -> ByteString -> ST st () Source #
Write a string whose bytes need no escape, between quotes.
putRawBytes :: Scratch st -> ByteString -> ST st () Source #
Write bytes as they are.
putDecimal :: Scratch st -> Int -> ST st () Source #
Write an integer in decimal, as aeson writes one.
putAt :: Scratch st -> Int -> (MutableByteArray st -> Int -> ST st Int) -> ST st () Source #
Write bytes at the cursor with the given writer, which returns the offset after them.
copyOut :: Scratch st -> Int -> Int -> ST st ByteArray Source #
A copy of the bytes between two offsets, in an array of their exact size.
decimalLength :: Int -> Int Source #
The bytes putDecimal writes.