Module IO.WriteContext
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 "= " 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.nullEdit your
dune-projectand add:(package (name YourExistingPackage) (depends ; ... existing dependenices ... (capnp (>= ))))Then run:
dune build *.opam # if this fails, run: dune buildEdit your
<package>.opamfile and add:depends: [ # ... existing dependencies ... "capnp" {>= ""} ]Then run:
opam install . --deps-only
FINALLY, add the capnp.unix library to any desired (library)and/or (executable) targets in your **/dune files:
(library
(name YourLibrary)
; ... existing library options ...
(libraries
; ... existing libraries ...
capnp.unix))
(executable
(name YourExecutable)
; ... existing executable options ...
(libraries
; ... existing libraries ...
capnp.unix))type``'a t
valcreate : ``write:``('a->``buf:string->``pos:int->``len:int->int)``->``compression:Capnp.Codecs.compression_t->'a->'at
create ~write ~compression descr creates a new context for writing
data to the specified descriptor. compression specifies the
compression format, if any.
The semantics of the write function shall mimic that of
Unix.single_write, attempting to write a substring from the buf and
returning the number of bytes actually written.
valenqueue_message :'at->'capCapnp.Message.BytesMessage.Message.t->unit
enqueue_message context message places the message in the outgoing
queue of the write context. No data will be written to the underlying
descriptor.
valbytes_remaining :'at->int
bytes_remaining context obtains the number of unwritten bytes
currently stored in the write context.
valwrite :'at->int
write context attempts to write some of the queued data to the
underlying descriptor associated with the write context.
-
returns
the number of bytes actually written
valwrite_message :'at->'capCapnp.Message.BytesMessage.Message.t->unit
write_message context message places the message in the outgoing
queue of the write context, then invokes write in a loop until all
queued data has been written.
