amber
Values
pub fn add_signal_listener(
signal: signal.Signal,
run handler: fn() -> any,
) -> Result(Nil, error.Error)
Registers a handler function to be called when the given OS signal is received.
pub fn build() -> build.Build
pub fn chdir(directory: String) -> Result(Nil, error.Error)
Changes the current working directory of the process.
pub fn chmod_sync(
path: String,
mode mode: Int,
) -> Result(Nil, error.Error)
pub fn chown_sync(
path: String,
uid uid: option.Option(Int),
gid gid: option.Option(Int),
) -> Result(Nil, error.Error)
Changes the owner of the file specified by path. Either uid or gid can
be set to None to leave that value unchanged.
pub fn connect(
port: Int,
) -> promise.Promise(Result(tcp_conn.TcpConn, error.Error))
Connects to the hostname (default is “127.0.0.1”) and port on the named
transport (default is “tcp”), and resolves to the connection (TcpConn).
pub fn connect_tls(
port: Int,
) -> promise.Promise(Result(tls_conn.TlsConn, error.Error))
Establishes a secure connection over TLS (transport layer security).
Uses Mozilla’s root certificates by default (see also https://github.com/ctz/webpki-roots for specifics).
pub fn connect_tls_with(
port: Int,
with options: List(connect_tls_option.ConnectTlsOption),
) -> promise.Promise(Result(tls_conn.TlsConn, error.Error))
Establishes a secure connection over TLS with options.
Custom CA certs, hostname, and mutual TLS (mTLS or client certificates) are supported through the options.
pub fn connect_with(
port: Int,
with options: List(connect_option.ConnectOption),
) -> promise.Promise(Result(tcp_conn.TcpConn, error.Error))
Connects to the given hostname and port with options.
pub fn console_size() -> Result(
console_size.ConsoleSize,
error.Error,
)
Gets the size of the console as columns/rows.
This returns the size of the console window as reported by the operating system. It’s not a reflection of how many characters will fit within the console window, but can be used as part of that calculation.
pub fn copy_file_sync(
from from_path: String,
to to_path: String,
) -> Result(Nil, error.Error)
pub fn create_sync(
path: String,
) -> Result(fs_file.FsFile, error.Error)
pub fn cwd() -> Result(String, error.Error)
pub fn exec_path() -> Result(String, error.Error)
pub fn exit() -> Nil
Terminates the current process with exit code 0. This function never returns.
pub fn exit_with(code: Int) -> Nil
Terminates the current process with the given exit code. This function never returns.
pub fn gid() -> Result(option.Option(Int), error.Error)
pub fn hostname() -> Result(String, error.Error)
pub fn inspect(value: a) -> String
Converts the input into a string that has the same format as printed by
console.log().
pub fn inspect_with(
value: a,
with options: List(inspect_option.InspectOption),
) -> String
pub fn is_no_color() -> Bool
pub fn kill(pid: Int) -> Result(Nil, error.Error)
Sends SIGTERM to the process with the given PID.
pub fn kill_with(
pid: Int,
with signal: signal.Signal,
) -> Result(Nil, error.Error)
Sends the given signal to the process with the given PID.
pub fn link_sync(
from oldpath: String,
to newpath: String,
) -> Result(Nil, error.Error)
Creates a hard link from oldpath to newpath.
pub fn listen(
port: Int,
) -> Result(listener.Listener, error.Error)
Listen announces on the local transport address.
pub fn listen_tls(
port: Int,
certified_key certified_key: tls_certified_key_pem.TlsCertifiedKeyPem,
) -> Result(tls_listener.TlsListener, error.Error)
Listen announces on the local transport address over TLS (transport layer security).
pub fn listen_tls_with(
port: Int,
certified_key certified_key: tls_certified_key_pem.TlsCertifiedKeyPem,
with options: List(listen_tls_option.ListenTlsOption),
) -> Result(tls_listener.TlsListener, error.Error)
Listen announces on the local transport address over TLS with options.
pub fn listen_with(
port: Int,
with options: List(listen_option.ListenOption),
) -> Result(listener.Listener, error.Error)
Listen announces on the local transport address with options.
pub fn loadavg() -> Result(#(Float, Float, Float), error.Error)
Returns the system load averages for the past 1, 5, and 15 minutes.
pub fn lstat_sync(
path: String,
) -> Result(file_info.FileInfo, error.Error)
pub fn main_module() -> String
pub fn make_temp_dir_sync() -> Result(String, error.Error)
Creates a new temporary directory in the default system temp directory and returns its path.
pub fn make_temp_dir_sync_with(
with options: List(make_temp.MakeTempOption),
) -> Result(String, error.Error)
pub fn make_temp_file_sync() -> Result(String, error.Error)
Creates a new temporary file in the default system temp directory and returns its path.
pub fn make_temp_file_sync_with(
with options: List(make_temp.MakeTempOption),
) -> Result(String, error.Error)
pub fn memory_usage() -> memory_usage.MemoryUsage
pub fn mkdir_sync(path: String) -> Result(Nil, error.Error)
pub fn mkdir_sync_with(
path: String,
with options: List(mkdir.MkdirOption),
) -> Result(Nil, error.Error)
pub fn network_interfaces() -> Result(
List(network_interface_info.NetworkInterfaceInfo),
error.Error,
)
Returns an array of the network interface information.
pub fn open_sync(
path: String,
) -> Result(fs_file.FsFile, error.Error)
pub fn open_sync_with(
path: String,
with options: List(open.OpenOption),
) -> Result(fs_file.FsFile, error.Error)
pub fn os_release() -> Result(String, error.Error)
pub fn os_uptime() -> Result(Int, error.Error)
pub fn read_dir_sync(
path: String,
) -> Result(List(dir_entry.DirEntry), error.Error)
pub fn read_file_sync(
path: String,
) -> Result(uint8_array.Uint8Array, error.Error)
pub fn read_link_sync(
path: String,
) -> Result(String, error.Error)
pub fn read_text_file_sync(
path: String,
) -> Result(String, error.Error)
pub fn real_path_sync(
path: String,
) -> Result(String, error.Error)
Resolves the given path to an absolute path, resolving all symlinks along the way.
pub fn ref_timer(id: Int) -> Nil
Makes the timer with the given ID block the event loop from finishing.
pub fn remove_signal_listener(
signal: signal.Signal,
run handler: fn() -> any,
) -> Result(Nil, error.Error)
Removes a previously registered OS signal handler.
pub fn remove_sync(path: String) -> Result(Nil, error.Error)
pub fn remove_sync_with(
path: String,
with options: List(remove.RemoveOption),
) -> Result(Nil, error.Error)
pub fn rename_sync(
from oldpath: String,
to newpath: String,
) -> Result(Nil, error.Error)
pub fn resolve_dns(
query: String,
record_type record_type: record_type.RecordType,
) -> promise.Promise(Result(List(String), error.Error))
Performs DNS resolution against the given query, returning resolved records
as strings. For structured record types (MX, SRV, etc.), use the
type-specific variants like resolve_dns_mx.
pub fn resolve_dns_caa(
query: String,
) -> promise.Promise(
Result(List(caa_record.CaaRecord), error.Error),
)
Performs DNS resolution for CAA records.
pub fn resolve_dns_caa_with(
query: String,
with options: List(resolve_dns_option.ResolveDnsOption),
) -> promise.Promise(
Result(List(caa_record.CaaRecord), error.Error),
)
pub fn resolve_dns_mx(
query: String,
) -> promise.Promise(
Result(List(mx_record.MxRecord), error.Error),
)
Performs DNS resolution for MX records.
pub fn resolve_dns_mx_with(
query: String,
with options: List(resolve_dns_option.ResolveDnsOption),
) -> promise.Promise(
Result(List(mx_record.MxRecord), error.Error),
)
pub fn resolve_dns_naptr(
query: String,
) -> promise.Promise(
Result(List(naptr_record.NaptrRecord), error.Error),
)
Performs DNS resolution for NAPTR records.
pub fn resolve_dns_naptr_with(
query: String,
with options: List(resolve_dns_option.ResolveDnsOption),
) -> promise.Promise(
Result(List(naptr_record.NaptrRecord), error.Error),
)
pub fn resolve_dns_soa(
query: String,
) -> promise.Promise(
Result(List(soa_record.SoaRecord), error.Error),
)
Performs DNS resolution for SOA records.
pub fn resolve_dns_soa_with(
query: String,
with options: List(resolve_dns_option.ResolveDnsOption),
) -> promise.Promise(
Result(List(soa_record.SoaRecord), error.Error),
)
pub fn resolve_dns_srv(
query: String,
) -> promise.Promise(
Result(List(srv_record.SrvRecord), error.Error),
)
Performs DNS resolution for SRV records.
pub fn resolve_dns_srv_with(
query: String,
with options: List(resolve_dns_option.ResolveDnsOption),
) -> promise.Promise(
Result(List(srv_record.SrvRecord), error.Error),
)
pub fn resolve_dns_txt(
query: String,
) -> promise.Promise(Result(List(List(String)), error.Error))
Performs DNS resolution for TXT records.
pub fn resolve_dns_txt_with(
query: String,
with options: List(resolve_dns_option.ResolveDnsOption),
) -> promise.Promise(Result(List(List(String)), error.Error))
pub fn resolve_dns_with(
query: String,
record_type record_type: record_type.RecordType,
with options: List(resolve_dns_option.ResolveDnsOption),
) -> promise.Promise(Result(List(String), error.Error))
pub fn set_exit_code(code: Int) -> Nil
Sets the process exit code used when the process exits naturally, without terminating immediately.
pub fn set_umask(mask: Int) -> Result(Int, error.Error)
Sets the process file mode creation mask and returns the previous value.
pub fn start_tls(
conn: tcp_conn.TcpConn,
) -> promise.Promise(Result(tls_conn.TlsConn, error.Error))
Start TLS handshake from an existing connection using the configured root certificates. Using this function requires that the other end of the connection is prepared for a TLS handshake.
Note that this function consumes the TCP connection passed to it,
thus the original TCP connection will be unusable after calling this.
Additionally, you need to ensure that the TCP connection is not being
used elsewhere when calling this function in order for the TCP
connection to be consumed properly. For instance, if there is a
Promise that is waiting for read operation on the TCP connection to
complete, it is considered that the TCP connection is being used
elsewhere. In such a case, this function will fail.
pub fn start_tls_with(
conn: tcp_conn.TcpConn,
with options: List(start_tls_option.StartTlsOption),
) -> promise.Promise(Result(tls_conn.TlsConn, error.Error))
Start TLS handshake from an existing connection with options.
pub fn stat_sync(
path: String,
) -> Result(file_info.FileInfo, error.Error)
pub fn symlink_sync(
from oldpath: String,
to newpath: String,
) -> Result(Nil, error.Error)
Creates a symbolic link from oldpath to newpath.
pub fn symlink_sync_with(
from oldpath: String,
to newpath: String,
with options: List(symlink.SymlinkOption),
) -> Result(Nil, error.Error)
pub fn system_memory_info() -> Result(
system_memory_info.SystemMemoryInfo,
error.Error,
)
pub fn truncate_sync(name: String) -> Result(Nil, error.Error)
pub fn truncate_to_length_sync(
name: String,
to len: Int,
) -> Result(Nil, error.Error)
pub fn uid() -> Result(option.Option(Int), error.Error)
pub fn unref_timer(id: Int) -> Nil
Makes the timer with the given ID not block the event loop from finishing.
pub fn upgrade_web_socket(
request: request.Request,
) -> Result(web_socket_upgrade.WebSocketUpgrade, error.Error)
Upgrade an incoming HTTP request to a WebSocket.
Given a Request, returns a WebSocketUpgrade containing a WebSocket
and Response. The original request must be responded to with the
returned response for the upgrade to be successful.
pub fn upgrade_web_socket_with(
request: request.Request,
with options: List(
upgrade_web_socket_option.UpgradeWebSocketOption,
),
) -> Result(web_socket_upgrade.WebSocketUpgrade, error.Error)
Upgrade an incoming HTTP request to a WebSocket with options.
pub fn utime_sync(
path: String,
atime atime: Int,
mtime mtime: Int,
) -> Result(Nil, error.Error)
Changes the access and modification times of the file at the given path. Timestamps are Unix timestamps in seconds.
pub fn version() -> version.Version
pub fn watch_fs(
paths: List(String),
) -> Result(fs_watcher.FsWatcher, error.Error)
Returns a watcher that yields file system events for the given paths.
pub fn watch_fs_with(
paths: List(String),
with options: List(watch_fs.WatchFsOption),
) -> Result(fs_watcher.FsWatcher, error.Error)
pub fn write_file_sync(
to path: String,
contents data: uint8_array.Uint8Array,
) -> Result(Nil, error.Error)
Writes the given data to the file at the specified path. Creates the file if it doesn’t exist, and truncates it if it does.
pub fn write_file_sync_with(
to path: String,
contents data: uint8_array.Uint8Array,
with options: List(write_file.WriteFileOption),
) -> Result(Nil, error.Error)
pub fn write_text_file_sync(
to path: String,
contents data: String,
) -> Result(Nil, error.Error)
Writes the given string data to the file at the specified path. Creates the file if it doesn’t exist, and truncates it if it does.
pub fn write_text_file_sync_with(
to path: String,
contents data: String,
with options: List(write_file.WriteFileOption),
) -> Result(Nil, error.Error)