Module Codecs.FramedStream
Contents
Instructions: Use this module in your project
In the IDE (CLion, Visual Studio Code, Xcode, etc.) you use for your DkSDK project:
Add the following to your project's
dependencies/CMakeLists.txt:DkSDKProject_DeclareAvailable(capnp CONSTRAINT "= 3.5.0" FINDLIBS capnp capnp.unix) DkSDKProject_MakeAvailable(capnp)Add the
Findlib::capnplibrary to any desired targets insrc/*/CMakeLists.txt:target_link_libraries(YourPackage_YourLibraryName # ... existing libraries, if any ... Findlib::capnp)Click your IDE's
Buildbutton
Not using DkSDK?
FIRST, do one or all of the following:
Run:
opam install capnp.3.5.0Edit your
dune-projectand add:(package (name YourExistingPackage) (depends ; ... existing dependenices ... (capnp (>= 3.5.0))))Then run:
dune build *.opam # if this fails, run: dune buildEdit your
<package>.opamfile and add:depends: [ # ... existing dependencies ... "capnp" {>= "3.5.0"} ]Then run:
opam install . --deps-only
FINALLY, add the capnp library to any desired (library)and/or (executable) targets in your **/dune files:
(library
(name YourLibrary)
; ... existing library options ...
(libraries
; ... existing libraries ...
capnp))
(executable
(name YourExecutable)
; ... existing executable options ...
(libraries
; ... existing libraries ...
capnp))typet
The type of streams containing framed messages.
valempty :compression_t->t
empty compression returns a new stream for decoding data stored with
the given compression method. The stream initially contains no data.
valof_string : ``compression:compression_t->``string->t
of_string ~compression buf returns a new stream which is filled with
the contents of the given buffer, where the buffer contains data
compressed with the specified compression method.
valadd_fragment :t->``string->unit
add_fragment stream fragment adds a new fragment to the stream for
decoding. Fragments are processed in FIFO order.
valbytes_available :t->int
bytes_available stream obtains the number of bytes in the stream which
have not yet been fully decoded.
valis_empty :t->bool
is_empty stream determines whether or not the stream contains any data
which has not yet been fully decoded.
valget_next_frame :t->``(Message.rwMessage.BytesMessage.Message.t,FramingError.t)``Result.result
get_next_frame attempts to decode the next frame from the stream. A
successful decode removes the data from the stream and returns the frame
data in the form of a BytesMessage.
