| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Registry.JsonStream
Contents
Description
Incremental registry extraction within a decompressed body ceiling. With the vendored json-stream and text 2.1.3, decoded strings and keys own their arrays, including chunk-spanning tokens. See decoder storage.
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))
- readJsonStream :: Monad m => BodyLimit -> Parser a -> (s -> a -> Either LimitError s) -> s -> m ByteString -> m (Either LimitError (StreamResult s))
- retainedValue :: Int -> Parser Value
- withinRetainedDepth :: Int -> Parser a -> Parser a
- data Members
- namedMembers :: [(Text, Parser Value)] -> Members
- everyMember :: Parser Value -> Members
- retainedObjectOr :: Value -> Members -> Parser Value
- 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 read in progress: it needs input, stops on a parse error or a refused value, or has finished. A read that writes as it goes resumes in its own effect.
Constructors
| NeedData (ByteString -> m (Steps m s)) | |
| Failed Text | |
| Refused LimitError | |
| Finished s |
Instances
| Build (Writer st) (ST st (Steps (ST st) s)) Source # | A value the writer holds in its scratch, which a read passes on as a mark only. Each step runs out of line, so a read's continuations hold the writer as one pointer. | ||||||||||||
Defined in Ecluse.Core.Registry.Json.Writer Associated Types
Methods sharedString :: Writer st -> Entry -> (Built (Writer st) -> ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source # ownString :: Writer st -> Name -> (Built (Writer st) -> ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source # integer :: Writer st -> Int -> (Built (Writer st) -> ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source # whole :: Writer st -> Value -> (Built (Writer st) -> ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source # emptyContainer :: Writer st -> (Built (Writer st) -> ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source # openObject :: Writer st -> (Fields (Writer st) -> ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source # beginMember :: Writer st -> MemberKey -> Fields (Writer st) -> (Bool -> ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source # addMember :: Writer st -> MemberKey -> Built (Writer st) -> Fields (Writer st) -> (Fields (Writer st) -> ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source # dropValue :: Writer st -> Built (Writer st) -> ST st (Steps (ST st) s) -> ST st (Steps (ST st) s) Source # closeObject :: Writer st -> Fields (Writer st) -> (Built (Writer st) -> ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source # openArray :: Writer st -> (Items (Writer st) -> ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source # addItem :: Writer st -> Built (Writer st) -> Items (Writer st) -> (Items (Writer st) -> ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source # closeArray :: Writer st -> Int -> Items (Writer st) -> (Built (Writer st) -> ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source # | |||||||||||||
| Walk (Steps Identity s) Source # | |||||||||||||
Defined in Ecluse.Core.Registry.Json.Walk Associated Types
| |||||||||||||
| Walk (ST st (Steps (ST st) s)) Source # | |||||||||||||
Defined in Ecluse.Core.Registry.Json.Walk Associated Types
| |||||||||||||
| type Result (Steps Identity s) Source # | |||||||||||||
Defined in Ecluse.Core.Registry.Json.Walk | |||||||||||||
| type Result (ST st (Steps (ST st) s)) Source # | |||||||||||||
Defined in Ecluse.Core.Registry.Json.Walk | |||||||||||||
readSteps :: Monad n => (forall a. m a -> n a) -> BodyLimit -> Steps m s -> n ByteString -> n (Either LimitError (StreamResult s)) Source #
Feed a read in pieces of at most 32 KiB, within the body ceiling, and drain the body after the read finishes. An empty chunk ends the body. The read resumes in its effect, run in the reader's.
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.
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.
Which members of an object are retained, with what parser, and under which key. Every object
read with one Members value holds each name it knows under one shared key.
namedMembers :: [(Text, Parser Value)] -> Members Source #
Retain only the named members. The first entry for a name wins.
everyMember :: Parser Value -> Members Source #
Retain every member with one parser, each under its own key.
retainedObjectOr :: Value -> Members -> Parser Value Source #
Supply an invalid-shape witness without traversing a valid object through a parallel fallback.
retainedScalar :: Parser Value Source #
Read a scalar without materialising an object or array when the field has the wrong shape.