ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Registry.JsonStream

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

Bounded reads

data StreamResult a Source #

Extracted data and the size of the complete decompressed source, including ignored fields.

Instances

Instances details
Show a => Show (StreamResult a) Source # 
Instance details

Defined in Ecluse.Core.Registry.JsonStream

Eq a => Eq (StreamResult a) Source # 
Instance details

Defined in Ecluse.Core.Registry.JsonStream

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

Instances details
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.

Instance details

Defined in Ecluse.Core.Registry.Json.Writer

Associated Types

type Built (Writer st) 
Instance details

Defined in Ecluse.Core.Registry.Json.Writer

type Built (Writer st) = ()
type Fields (Writer st) 
Instance details

Defined in Ecluse.Core.Registry.Json.Writer

type Fields (Writer st) = Frame
type Items (Writer st) 
Instance details

Defined in Ecluse.Core.Registry.Json.Writer

type Items (Writer st) = Int

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 # 
Instance details

Defined in Ecluse.Core.Registry.Json.Walk

Associated Types

type Result (Steps Identity s) 
Instance details

Defined in Ecluse.Core.Registry.Json.Walk

type Result (Steps Identity s) = s
Walk (ST st (Steps (ST st) s)) Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Walk

Associated Types

type Result (ST st (Steps (ST st) s)) 
Instance details

Defined in Ecluse.Core.Registry.Json.Walk

type Result (ST st (Steps (ST st) s)) = s

Methods

needData :: (ByteString -> ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source #

failWith :: Text -> ST st (Steps (ST st) s) Source #

refuse :: LimitError -> ST st (Steps (ST st) s) Source #

finish :: Result (ST st (Steps (ST st) s)) -> ST st (Steps (ST st) s) Source #

type Result (Steps Identity s) Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Walk

type Result (Steps Identity s) = s
type Result (ST st (Steps (ST st) s)) Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Walk

type Result (ST st (Steps (ST st) s)) = s

type Step = Steps Identity Source #

A read with no effect of its own.

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.

data Members Source #

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.

retainedObjectWith :: Parser Value -> Members -> Parser Value Source #

Select object events before folding. The fallback handles scalars and other container shapes.

retainedArrayWith :: Parser Value -> Parser Value -> Parser Value Source #

Select array events before folding. A container fallback must yield only its completed value.