baml.net.TcpStream
A TCP connection. Created by `baml.net.TcpStream.connect` or returned by `baml.net.TcpListener.accept`.
Signature
class baml.net.TcpStreamA TCP connection. Created by baml.net.TcpStream.connect or returned by
baml.net.TcpListener.accept.
Implements baml.io.Read and baml.io.Write.
Source:<builtin>/baml/ns_net/net.bamlbytes 167–1827
Fields
_handle
$rust_type(internal)
Static methods
_connect
((internal)
connect
(Opens a TCP connection to addr (e.g. "127.0.0.1:8080") and returns the stream.
timeout bounds how long to wait for the connection to be established;
null (the default) waits indefinitely (subject to the OS default). On
expiry this throws baml.errors.Timeout.
Instance methods
Closes the connection.
Implementations
baml.Concrete for T
Static methods
type
() -> reflect.Type throws neverThis type's runtime type value: int.type() is the same value as
reflect.Type.of<int>().
Spell it on a declared type written as one name, optionally qualified
or with generic arguments: Foo.type(), root.models.Base.type(),
Box<int[]>.type(). Array, optional, union, map and function types,
interfaces, and generic type parameters keep the reflect.Type.of<T>()
form. A type that declares its own type member keeps resolving to it.
Source:<builtin>/baml/core.bamlbytes 1360–1392
baml.io.Read for baml.net.TcpStream
Instance methods
Consume all remaining bytes through EOF.
Read at most limit bytes. Blocks until data or EOF is available.
Consume all remaining bytes through EOF and decode strict UTF-8.
Source:<builtin>/baml/ns_net/net.bamlbytes 1135–1364
baml.io.Write for baml.net.TcpStream
Instance methods
flush
(self) -> null throws neverNo-op because TCP streams are unbuffered.
Write all of data to the destination.
Strings are encoded as UTF-8.
Returns the number of bytes written.
Like Rust's write_all, this does not flush: it is a loop over
write_some, and pushing buffered bytes onward stays the caller's
separate flush. Implementors are expected to make write_some report
its own failures rather than defer them.
Attempt one write and return the number of bytes accepted.
Source:<builtin>/baml/ns_net/net.bamlbytes 1370–1704