| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Registry.JsonStream
Contents
Description
Incremental registry extraction within a decompressed body ceiling. The maintained lexer copies decoded strings and keys into owned arrays, including chunk-spanning tokens. Opaque cursors can retain input slices until the walk advances.
Synopsis
- data StreamResult a = StreamResult {
- streamValue :: Either ParseError a
- streamBytes :: Int
- data Steps (m :: Type -> Type) s
- = NeedData (ByteString -> m (Steps m s))
- | Failed Text
- | Refused LimitError
- | Finished s
- type Step = Steps Identity
- readSteps :: Monad n => (forall a. m a -> n a) -> BodyLimit -> Steps m s -> n ByteString -> n (Either LimitError (StreamResult s))
- readStepsWithEnd :: Monad n => (forall a. m a -> n a) -> (Steps m s -> n (Steps m s)) -> BodyLimit -> Steps m s -> n ByteString -> n (Either LimitError (StreamResult s))
- readJsonStream :: Monad m => BodyLimit -> Parser a -> (s -> a -> Either LimitError s) -> s -> m ByteString -> m (Either LimitError (StreamResult s))
- maxChunkBytes :: Int
- retainedValue :: Int -> Parser Value
- withinRetainedDepth :: Int -> Parser a -> Parser a
- nestingLimit :: Text
- isNestingLimit :: ParseError -> Bool
- isJsonSpace :: Word8 -> Bool
- data Members
- everyMember :: Parser Value -> Members
- retainedScalar :: Parser Value
- retainedObjectWith :: Parser Value -> Members -> Parser Value
- retainedArrayWith :: Parser Value -> Parser Value -> Parser Value
Bounded reads
data StreamResult a Source #
Extracted data and the size of the complete decompressed source, including ignored fields.
Constructors
| StreamResult | |
Fields
| |
Instances
| Show a => Show (StreamResult a) Source # | |
Defined in Ecluse.Core.Registry.JsonStream Methods showsPrec :: Int -> StreamResult a -> ShowS # show :: StreamResult a -> String # showList :: [StreamResult a] -> ShowS # | |
| Eq a => Eq (StreamResult a) Source # | |
Defined in Ecluse.Core.Registry.JsonStream Methods (==) :: StreamResult a -> StreamResult a -> Bool # (/=) :: StreamResult a -> StreamResult a -> Bool # | |
data Steps (m :: Type -> Type) s Source #
A suspended, failed, refused or finished read. Writing reads resume in their own effect.
Constructors
| NeedData (ByteString -> m (Steps m s)) | |
| Failed Text | |
| Refused LimitError | |
| Finished s |
Instances
readSteps :: Monad n => (forall a. m a -> n a) -> BodyLimit -> Steps m s -> n ByteString -> n (Either LimitError (StreamResult s)) Source #
Enforce the body ceiling with pieces of at most 32 KiB, then drain until an empty chunk ends the body.
readStepsWithEnd :: Monad n => (forall a. m a -> n a) -> (Steps m s -> n (Steps m s)) -> BodyLimit -> Steps m s -> n ByteString -> n (Either LimitError (StreamResult s)) Source #
Finalise a framed read at EOF without feeding an invented source byte to its consumer.
readJsonStream :: Monad m => BodyLimit -> Parser a -> (s -> a -> Either LimitError s) -> s -> m ByteString -> m (Either LimitError (StreamResult s)) Source #
Fold each value the parser yields through the step, as readSteps feeds it.
maxChunkBytes :: Int Source #
The largest piece of a chunk a read feeds its consumer at once.
Retained values
retainedValue :: Int -> Parser Value Source #
Decode a retained field within a structural budget. Unknown fields never call this parser.
withinRetainedDepth :: Int -> Parser a -> Parser a Source #
Charge the parsed value's own level, including empty containers. Children need one less level.
nestingLimit :: Text Source #
The parse error that marks a retained value past its structural budget.
isNestingLimit :: ParseError -> Bool Source #
Distinguish a retained-depth refusal from malformed JSON.
isJsonSpace :: Word8 -> Bool Source #
JSON permits only space, tab, CR and LF as whitespace.
Object member selection. Named members share each stored key across retained objects.
everyMember :: Parser Value -> Members Source #
Retain every member with one parser, each under its own key.
retainedScalar :: Parser Value Source #
Read a scalar without materialising an object or array when the field has the wrong shape.