Module Capnp_unix.IO
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 in- src/*/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.null
- Edit your - dune-projectand add:- (package (name YourExistingPackage) (depends ; ... existing dependenices ... (capnp (>= ))))- Then run: - dune build *.opam # if this fails, run: dune build
- Edit 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))exceptionUnsupported_message_frame
moduleWriteContext:sig...end
moduleReadContext:sig...end
valcreate_write_context_for_fd : ``?restart:bool->``compression:Capnp.Codecs.compression_t->Unix.file_descr->Unix.file_descrWriteContext.t
create_write_context_for_fd ~compression fd creates a context for
writing messages to the given file descriptor using the specified
compression format. If restart is set to true (default), then
writes failing with error code Unix.EINTR will be automatically
restarted.
valcreate_write_context_for_channel : ``compression:Capnp.Codecs.compression_t->out_channel->out_channelWriteContext.t
create_write_context_for_channel ~compression chan creates a context
for writing messages to the given buffered output channel using the
specified compression format.
valcreate_read_context_for_fd : ``?restart:bool->``compression:Capnp.Codecs.compression_t->Unix.file_descr->Unix.file_descrReadContext.t
create_read_context_for_fd ~compression fd creates a context for
reading messages from the given file descriptor using the specified
compression method. If restart is set to true (default), then
writes failing with error code Unix.EINTR will be automatically
restarted.
valcreate_read_context_for_channel : ``compression:Capnp.Codecs.compression_t->in_channel->in_channelReadContext.t
create_read_context_for_channel ~compression chan creates a context
for reading messages from the given input channel using the specified
compression method.
valwrite_message_to_fd : ``?restart:bool->``compression:Capnp.Codecs.compression_t->'capCapnp.Message.BytesMessage.Message.t->Unix.file_descr->unit
write_message_to_fd ~compression message fd writes the specified
message to the given file descriptor, using the specified
compression method. If restart is set to true (default), then
writes failing with error code Unix.EINTR will be automatically
restarted.
EAGAIN/EWOULDBLOCK are handled automatically.
- 
raises Unix.Unix_error if a write fails 
valwrite_message_to_channel : ``compression:Capnp.Codecs.compression_t->'capCapnp.Message.BytesMessage.Message.t->out_channel->unit
write_message_to_channel ~compression message chan writes the
specified message to the given buffered I/O channel, using the
specified compression method.
valwrite_message_to_file : ``?perm:int->``compression:Capnp.Codecs.compression_t->'capCapnp.Message.BytesMessage.Message.t->``string->unit
write_message_to_file ~compression message filename writes the
specified message to a file with the given filename, using the
requested compression method. The optional perm specifies the file
creation mode, in case a new file must be created.
valread_single_message_from_fd : ``?restart:bool->``compression:Capnp.Codecs.compression_t->Unix.file_descr->Capnp.Message.rwCapnp.Message.BytesMessage.Message.toption
read_single_message_from_fd ~compression fd attempts to read a single
message from the specified file descriptor, using the given
compression method. If restart is set to true (default), then
writes failing with error code Unix.EINTR will be automatically
restarted.
EAGAIN/EWOULDBLOCK are handled automatically.
This function is appropriate to use only when 0 or 1 messages are
expected to be available from the descriptor; if additional messages are
available, some message data could be lost. Use
create_XXX_read_context_for_fd to correctly handle a stream of
messages.
- 
returns Some message, or None if end-of-file was reached before a message could be decoded. 
- 
raises Unix.Unix_error if a read fails 
- 
raises Unsupported_message_frame if the frame header describes a segment count or segment size that is too large for the implementation 
valread_single_message_from_channel : ``compression:Capnp.Codecs.compression_t->in_channel->Capnp.Message.rwCapnp.Message.BytesMessage.Message.toption
read_single_message_from_channel ~compression chan attempts to read a
single message from the specified input channel, using the given
compression method.
This function is appropriate to use only when 0 or 1 messages are
expected to be available from the channel; if additional messages are
available, some message data could be lost. Use
create_XXX_read_context_for_channel to correctly handle a stream of
messages.
- 
returns Some message, or None if end-of-file was reached before a message could be decoded. 
- 
raises Unsupported_message_frame if the frame header describes a segment count or segment size that is too large for the implementation 
valread_message_from_file : ``compression:Capnp.Codecs.compression_t->``string->Capnp.Message.rwCapnp.Message.BytesMessage.Message.toption
read_message_from_file ~compression filename attempts to read a
message from the file with the given filename, using the requested
compression method.
- 
returns Some message, or None if the file does not contain a complete message frame. 
