Axle v0.22.0
Package

std/net/tls

TLS bindings — the encrypted transport behind an https:// URL.

Bound with @link(symbol = …) against axle_tls, a staticlib of its own. That
separation is what keeps TLS off a program that does not ask for it: the
archive is on every link line, and the linker includes objects, not
archives, so naming none of these symbols links none of the stack.

Nothing here raises. Every binding answers a code, and the caller reads
tlsLastError() for the reason — the Rust side has no way to raise an
Axle exception without depending on the runtime, which would cost it its
place as a leaf.

Free functions

TypeMethod and description
i64
tlsConnect(host : string, port : i32, timeoutMillis : i32) : i64 Open a TLS connection to host:port, answering a handle or 0.
timeoutMillis bounds the connect and every later read and write; 0
leaves the OS default.
i32
tlsRead(handle : i64, buf : ptr, max : i32) : i32 Up to max decrypted bytes: the count, 0 at end of stream, -1 on
failure. A null buffer or a non-positive max is also -1, never 0.
i32
tlsWrite(handle : i64, buf : ptr, len : i32) : i32 Encrypt and send; answers how many bytes were taken, or -1. A null buffer
or a non-positive len is -1, never 0.
void
tlsClose(handle : i64) : void Send close-notify and release the handle. An unknown handle is a no-op.
i32
tlsLastErrorInto(buf : ptr, max : i32) : i32 Copy this thread's last error into buf, answering its byte length.
string
tlsLastError() : string This thread's last transport error, as text.

Read immediately after the call that failed: the slot is per-thread and
every fallible binding clears it on entry, so a stale message can never
be mistaken for this call's reason.

Method detail

#tlsConnect

tlsConnect(host : string, port : i32, timeoutMillis : i32) : i64

Open a TLS connection to host:port, answering a handle or 0.
timeoutMillis bounds the connect and every later read and write; 0
leaves the OS default.

#tlsRead

tlsRead(handle : i64, buf : ptr, max : i32) : i32

Up to max decrypted bytes: the count, 0 at end of stream, -1 on
failure. A null buffer or a non-positive max is also -1, never 0.

#tlsWrite

tlsWrite(handle : i64, buf : ptr, len : i32) : i32

Encrypt and send; answers how many bytes were taken, or -1. A null buffer
or a non-positive len is -1, never 0.

#tlsClose

tlsClose(handle : i64) : void

Send close-notify and release the handle. An unknown handle is a no-op.

#tlsLastErrorInto

tlsLastErrorInto(buf : ptr, max : i32) : i32

Copy this thread's last error into buf, answering its byte length.

#tlsLastError

tlsLastError() : string

This thread's last transport error, as text.

Read immediately after the call that failed: the slot is per-thread and
every fallible binding clears it on entry, so a stale message can never
be mistaken for this call's reason.