Skip to main content

Module connections

Module connections 

Source
Expand description

Connection object builtins — file connections, stdin/stdout/stderr, TCP sockets.

R connections wrap file handles (or other I/O sources) behind integer IDs. This module provides: file(), open(), close(), isOpen(), readLines()/writeLines() connection dispatch, the three standard stream constructors stdin(), stdout(), stderr(), and TCP client socket builtins: make.socket(), read.socket(), write.socket(), close.socket().

Connection metadata lives on the Interpreter struct as a Vec<ConnectionInfo>. Slots 0-2 are pre-allocated for stdin, stdout, and stderr.

TCP streams (std::net::TcpStream) are not Clone, so they are stored separately in a HashMap<usize, TcpStream> keyed by connection ID.

Structs§

ConnectionInfo
Describes a single connection slot in the interpreter.

Enums§

ConnectionKind
Discriminates what kind of I/O backing a connection has.

Statics§

__INTERP_REG_INTERP_CLOSE 🔒
__INTERP_REG_INTERP_CLOSE_SOCKET 🔒
__INTERP_REG_INTERP_FILE 🔒
__INTERP_REG_INTERP_IS_OPEN 🔒
__INTERP_REG_INTERP_MAKE_SOCKET 🔒
__INTERP_REG_INTERP_OPEN 🔒
__INTERP_REG_INTERP_READ_LINES 🔒
__INTERP_REG_INTERP_READ_SOCKET 🔒
__INTERP_REG_INTERP_STDERR 🔒
__INTERP_REG_INTERP_STDIN 🔒
__INTERP_REG_INTERP_STDOUT 🔒
__INTERP_REG_INTERP_WRITE_LINES 🔒
__INTERP_REG_INTERP_WRITE_SOCKET 🔒

Functions§

connection_id 🔒
Extract a connection ID from an argument that is either an integer (possibly with class “connection”) or a double that can be losslessly converted.
connection_value 🔒
Build an integer scalar with class "connection" representing connection id.
interp_close 🔒
Close a connection or progress bar.
interp_close_socket 🔒
Close a TCP socket connection.
interp_file 🔒
Create a file connection.
interp_is_open 🔒
Test whether a connection is open.
interp_make_socket 🔒
Create a TCP client socket connection.
interp_open 🔒
Open a connection.
interp_read_lines 🔒
Read text lines from a file path or a connection.
interp_read_socket 🔒
Read up to maxlen bytes from a TCP socket connection.
interp_stderr 🔒
Return connection 2 (standard error).
interp_stdin 🔒
Return connection 0 (standard input).
interp_stdout 🔒
Return connection 1 (standard output).
interp_write_lines 🔒
Write text lines to a file path, connection, or stdout.
interp_write_socket 🔒
Write a string to a TCP socket connection.
is_connection 🔒
Returns true if val carries the "connection" class attribute.
resolved_path_string 🔒