ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Registry.Json.Writer

Description

The packed form's writer: a Build that writes each value's opcodes into one scratch buffer per read as the walk reads it, and copies each finished release or file into a blob of its own. An object's members are written in source order, and at the object's end they are copied behind their count in key order, the first member under each key kept.

Synopsis

Documentation

data Writer st Source #

One read's scratch, and what an open object has recorded of each member: its key, where its value's bytes lie, and which earlier member under the same table key it hides.

Instances

Instances details
TableStrings Writer Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Writer

Methods

tableValue :: Writer st -> Int -> ST st Value Source #

tableKey :: Writer st -> Int -> ST st Key Source #

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 #

type Built (Writer st) Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Writer

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

Defined in Ecluse.Core.Registry.Json.Writer

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

Defined in Ecluse.Core.Registry.Json.Writer

type Items (Writer st) = Int

newWriter :: Maybe (Entry, Entry) -> ST st (Writer st) Source #

A writer for one read. Each top-level object also holds the given member, a table key and a string, in place of its own under that key. An object read in Keep mode keeps its own instead.

data Frame Source #

An object being written: where its bytes start, and its first member's record.

sealValue :: Writer st -> [Text] -> ST st Packed Source #

Copy the value the writer holds into a packed value, and empty the scratch for the next one. Its hole is the string at the path of member names, when the value holds one there.

data Pick Source #

Which parts of a packed value a decode needs: all of it, or the named members of an object.

Constructors

Whole 
Only [(Text, Pick)] 

decodePicked :: Writer st -> Pick -> Packed -> ST st Value Source #

The parts of a packed value the pick names, as aeson's tree sharing the read's strings. A value that is not an object where the pick names members decodes whole.

decodeWhole :: Writer st -> Packed -> ST st Value Source #

A packed value decoded whole, sharing the read's strings.

replacedMember :: Writer st -> ST st (Maybe Value) Source #

The member the added member replaced in the value sealed last, as read, or nothing when that value held none or the writer discarded a value since.

discard :: Writer st -> ST st () Source #

Forget the value the writer holds, and the member its top-level object replaced.