Safe Haskell | None |
---|---|
Language | Haskell2010 |
In particular
Text
andData
(which are primitive types in the schema language, but are both the same asList(UInt8)
on the wire).- Lists of types other than those in Capnp.Untyped.
Whereas
ListOf
only deals with low-level encodings of lists, this module'sList
type can represent typed lists.
Synopsis
- data Text msg
- newtype Data msg = Data (ListOf msg Word8)
- class ListElem msg e where
- class ListElem (MutMsg s) e => MutListElem s e where
- getData :: ReadCtx m msg => ListOf msg Word8 -> m (Data msg)
- getText :: ReadCtx m msg => ListOf msg Word8 -> m (Text msg)
- newData :: WriteCtx m s => MutMsg s -> Int -> m (Data (MutMsg s))
- newText :: WriteCtx m s => MutMsg s -> Int -> m (Text (MutMsg s))
- dataBytes :: ReadCtx m msg => Data msg -> m ByteString
- textBuffer :: ReadCtx m msg => Text msg -> m (ListOf msg Word8)
- textBytes :: ReadCtx m msg => Text msg -> m ByteString
Documentation
A textual string (Text
in capnproto's schema language). On the wire,
this is NUL-terminated. The encoding should be UTF-8, but the library
does not verify this; users of the library must do validation themselves, if
they care about this.
Rationale: validation would require doing an up-front pass over the data, which runs counter to the overall design of capnproto.
A blob of bytes (Data
in capnproto's schema language). The argument
to the data constructor is a slice into the message, containing the raw
bytes.
class ListElem msg e where Source #
Types which may be stored as an element of a capnproto list.
listFromPtr :: ReadCtx m msg => msg -> Maybe (Ptr msg) -> m (List msg e) Source #
Convert an untyped list to a list of this type. May fail
with a SchemaViolationError
if the list does not have the
correct representation.
TODO: this is basically just fromPtr; refactor so this is less redundant.
toUntypedList :: List msg e -> List msg Source #
length :: List msg e -> Int Source #
Get the length of a list.
index :: ReadCtx m msg => Int -> List msg e -> m e Source #
gets the index
i listi
th element of a list.
Instances
class ListElem (MutMsg s) e => MutListElem s e where Source #
Types which may be stored as an element of a *mutable* capnproto list.
setIndex :: RWCtx m s => e -> Int -> List (MutMsg s) e -> m () Source #
sets the setIndex
value i listi
th index in list
to value
newList :: WriteCtx m s => MutMsg s -> Int -> m (List (MutMsg s) e) Source #
allocates and returns a new list of length
newList
msg sizesize
inside msg
.
Instances
newData :: WriteCtx m s => MutMsg s -> Int -> m (Data (MutMsg s)) Source #
allocates a new data blob of length newData
msg lenlen
bytes
inside the message.
dataBytes :: ReadCtx m msg => Data msg -> m ByteString Source #
Convert a Data
to a ByteString
.
textBuffer :: ReadCtx m msg => Text msg -> m (ListOf msg Word8) Source #
Return the underlying buffer containing the text. This does not include the null terminator.
textBytes :: ReadCtx m msg => Text msg -> m ByteString Source #
Convert a Text
to a ByteString
, comprising the raw bytes of the text
(not counting the NUL terminator).