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 mut
- newtype Data mut = Data (ListOf mut Word8)
- class ListElem mut e where
- class ListElem ('Mut s) e => MutListElem s e where
- getData :: ReadCtx m mut => ListOf mut Word8 -> m (Data mut)
- getText :: ReadCtx m mut => ListOf mut Word8 -> m (Text mut)
- newData :: WriteCtx m s => Message ('Mut s) -> Int -> m (Data ('Mut s))
- newText :: WriteCtx m s => Message ('Mut s) -> Int -> m (Text ('Mut s))
- dataBytes :: ReadCtx m 'Const => Data 'Const -> m ByteString
- textBuffer :: ReadCtx m mut => Text mut -> m (ListOf mut Word8)
- textBytes :: ReadCtx m 'Const => Text 'Const -> 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.
Instances
ToPtr s (Text ('Mut s)) Source # | |
FromPtr mut (Text mut) Source # | |
MutListElem s (Text ('Mut s)) Source # | |
ListElem mut (Text mut) Source # | |
Defined in Capnp.Basics | |
Thaw (Text 'Const) Source # | |
Defined in Capnp.Basics thaw :: (PrimMonad m, PrimState m ~ s) => Text 'Const -> m (Mutable s (Text 'Const)) Source # freeze :: (PrimMonad m, PrimState m ~ s) => Mutable s (Text 'Const) -> m (Text 'Const) Source # unsafeThaw :: (PrimMonad m, PrimState m ~ s) => Text 'Const -> m (Mutable s (Text 'Const)) Source # unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => Mutable s (Text 'Const) -> m (Text 'Const) Source # | |
type Mutable s (Text 'Const) Source # | |
newtype List mut (Text mut) Source # | |
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.
Instances
ToPtr s (Data ('Mut s)) Source # | |
FromPtr mut (Data mut) Source # | |
MutListElem s (Data ('Mut s)) Source # | |
ListElem mut (Data mut) Source # | |
Defined in Capnp.Basics | |
Thaw (Data 'Const) Source # | |
Defined in Capnp.Basics thaw :: (PrimMonad m, PrimState m ~ s) => Data 'Const -> m (Mutable s (Data 'Const)) Source # freeze :: (PrimMonad m, PrimState m ~ s) => Mutable s (Data 'Const) -> m (Data 'Const) Source # unsafeThaw :: (PrimMonad m, PrimState m ~ s) => Data 'Const -> m (Mutable s (Data 'Const)) Source # unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => Mutable s (Data 'Const) -> m (Data 'Const) Source # | |
type Mutable s (Data 'Const) Source # | |
newtype List mut (Data mut) Source # | |
class ListElem mut e where Source #
Types which may be stored as an element of a capnproto list.
listFromPtr :: ReadCtx m mut => Message mut -> Maybe (Ptr mut) -> m (List mut 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 mut e -> List mut Source #
length :: List mut e -> Int Source #
Get the length of a list.
index :: ReadCtx m mut => Int -> List mut e -> m e Source #
gets the index
i listi
th element of a list.
Instances
class ListElem ('Mut 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 ('Mut s) e -> m () Source #
sets the setIndex
value i listi
th index in list
to value
newList :: WriteCtx m s => Message ('Mut s) -> Int -> m (List ('Mut s) e) Source #
allocates and returns a new list of length
newList
msg sizesize
inside msg
.
Instances
newData :: WriteCtx m s => Message ('Mut s) -> Int -> m (Data ('Mut s)) Source #
allocates a new data blob of length newData
msg lenlen
bytes
inside the message.
dataBytes :: ReadCtx m 'Const => Data 'Const -> m ByteString Source #
Convert a Data
to a ByteString
.
textBuffer :: ReadCtx m mut => Text mut -> m (ListOf mut Word8) Source #
Return the underlying buffer containing the text. This does not include the null terminator.
textBytes :: ReadCtx m 'Const => Text 'Const -> m ByteString Source #
Convert a Text
to a ByteString
, comprising the raw bytes of the text
(not counting the NUL terminator).