attach
fn attach(Stream s, int ptr, int read, int write, int shutdown, int free) -> Result<Stream, IoError> Import
Source: use io::{attach}; compiler/src/builtin_docs/io.hy Installs package IO hooks on s in place; the free-function form of Stream.attach.
ptr is the package’s session pointer and read, write, shutdown
and free are C function pointers (as int, usually looked up through
dload). Afterwards read / write on s go through those hooks and
close calls shutdown then free. Returns s.
Returns Err(IoError::InvalidInput) when ptr is 0 or s is already
attached, and Err(IoError::AlreadyClosed) on a closed stream. A program
that reaches attach compiles only with --allow-attach.
Parameters#
| Name | Type |
|---|---|
s | Stream |
ptr | int |
read | int |
write | int |
shutdown | int |
free | int |
Returns#
Result<Stream, IoError>
Examples#
use io::{attach};
use io::net::tcp::{connect};
let s = connect("example.com", 443)?;
// session, rd, wr, sd, fr: a session pointer and C hooks from a dload'ed library
let tls = attach(s, session, rd, wr, sd, fr)?;
See also#
Stream::attachintio::closestdin: Returns a new stream on the process’s standard input.stdout: Returns a new stream on the process’s standard output.stderr: Returns a new stream on the process’s standard error.capture_begin: Starts keeping this thread’s stdout and stderr writes in memory instead of writing them, until the matchingcapture_end().capture_end: Ends the innermostcapture_begin()and returns what it kept, as(stdout, stderr).