package capnp
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=20221b396b17c654e5d0870761bef50c5a5dc99bc578e31980bac76dae1d3560
md5=1c8519640a3e5f06c48220d2194d9d36
doc/capnp.unix/Capnp_unix/IO/index.html
Module Capnp_unix.IO
module WriteContext : sig ... end
module ReadContext : sig ... end
val create_write_context_for_fd :
?restart:bool ->
compression:Capnp.Codecs.compression_t ->
Unix.file_descr ->
Unix.file_descr WriteContext.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.
val create_write_context_for_channel :
compression:Capnp.Codecs.compression_t ->
Pervasives.out_channel ->
Pervasives.out_channel WriteContext.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.
val create_read_context_for_fd :
?restart:bool ->
compression:Capnp.Codecs.compression_t ->
Unix.file_descr ->
Unix.file_descr ReadContext.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.
val create_read_context_for_channel :
compression:Capnp.Codecs.compression_t ->
Pervasives.in_channel ->
Pervasives.in_channel ReadContext.t
create_read_context_for_channel ~compression chan
creates a context for reading messages from the given input channel using the specified compression
method.
val write_message_to_fd :
?restart:bool ->
compression:Capnp.Codecs.compression_t ->
'cap Capnp.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.
val write_message_to_channel :
compression:Capnp.Codecs.compression_t ->
'cap Capnp.Message.BytesMessage.Message.t ->
Pervasives.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.
val write_message_to_file :
?perm:int ->
compression:Capnp.Codecs.compression_t ->
'cap Capnp.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.
val write_message_to_file_robust :
?perm:int ->
compression:Capnp.Codecs.compression_t ->
'cap Capnp.Message.BytesMessage.Message.t ->
string ->
unit
As write_message_to_file
, but the file is constructed transactionally by writing to a temporary file and renaming to the filename
, and Unix.fsync
is used carefully to ensure durability of the write.
The overhead of rename
and fsync
may lead to reduced throughput relative to write_message_to_file
.
val read_single_message_from_fd :
?restart:bool ->
compression:Capnp.Codecs.compression_t ->
Unix.file_descr ->
Capnp.Message.rw Capnp.Message.BytesMessage.Message.t option
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.
val read_single_message_from_channel :
compression:Capnp.Codecs.compression_t ->
Pervasives.in_channel ->
Capnp.Message.rw Capnp.Message.BytesMessage.Message.t option
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.
val read_message_from_file :
compression:Capnp.Codecs.compression_t ->
string ->
Capnp.Message.rw Capnp.Message.BytesMessage.Message.t option
read_message_from_file ~compression filename
attempts to read a message from the file with the given filename
, using the requested compression
method.