Skip to main content

Crate fetchlet

Crate fetchlet 

Source
Expand description

JavaScript functions and Fetch handlers hosted by Rust.

Re-exports§

pub use http;

Structs§

App
A managed, reusable application instance with fixed host bindings.
AppBuilder
AppHandle
A cloneable Send + Sync handle to one application on its worker threads.
Boa
BoaOptions
Boa interpreter limits. None uses the engine’s own setting (10,240 value stack slots and 512 nested calls in Boa 0.22).
Body
An HTTP body owned by fetchlet.
Call
A call of an exported function: its arguments, which are JSON values, byte arrays and channels Rust lends to it, and the trusted Context of its invocation.
CallOutput
The result of an exported function: the JSON value JSON.stringify made of it, with each ArrayBuffer or view inside it as bytes.
ChannelEnd
Rust’s end of a channel whose other end is JavaScript in one invocation.
ChannelRequest
A channel JavaScript asked a ChannelService to open, with env.NAME.connect(options).
CloseFrame
How a channel ended, in WebSocket’s close code space (RFC 6455 §7.4).
Context
Trusted, request-scoped values that Rust supplies to in-process services.
FetchApp
Low-level Fetch adapter; prefer App for managed deadlines and host services.
FetchPolicy
Exact normalized origins; no wildcard or substring matching.
FetchService
A transport with an origin policy and optional trusted request callbacks.
FunctionError
The failure of a Functions method.
FunctionRequest
What a Functions method receives when JavaScript calls it: the method’s name, its arguments and the invocation’s trusted Context.
FunctionResponse
The result of a Functions method: a JSON value, with byte arrays and channels at positions inside it.
Functions
Rust functions that JavaScript calls as the methods of env.NAME.
HeldConnection
A place among the Instances::max_held_connections of an AppHandle, from AppHandle::reserve_connection.
HostServices
Fixed bindings and services for one App. No process environment is inherited.
Instances
The instances of an AppHandle, each on its own worker thread and each running one call at a time.
Limits
Resource budgets selected by the embedding application.
Module
A prebuilt script exposing named functions through fetchletExports, with what it needs from the host that runs it.
OriginRouter
Exact-origin routing of host fetches to registered transports.
PoolState
What the instances and queue of an AppHandle are doing, from AppHandle::pool_state, for operators to size Instances and the queue from their own load.
ProcessOptions
How the child process of an isolated instance starts and what bounds it.
QuickJs
QuickJsOptions
QuickJS resource settings. None uses the engine’s own setting. The heap budget is Limits::heap_bytes, which every engine that can enforce one shares.
RequireHttp2
A request extension that FetchService adds when the request’s body streams and its policy does not allow that over HTTP/1.x (FetchPolicy::allow_http1_streaming).
Requirements
What a module needs from the host that runs it, as fetchlet/build records in an artifact’s manifest: native engine APIs and the locales they must support, the engine’s async context, and the Web APIs and protocol of fetchlet-web.
ServerWebSocket
The response extension of a Fetch handler that accepted a WebSocket upgrade with upgradeWebSocket(request).
SocketAddress
A TCP destination: a host name or IP literal, and a port.
SocketPolicy
Exact normalized hosts, each with the ports it allows; no wildcard or suffix matching.
SocketRequest
A TCP connection JavaScript asked for with connect(address, options).
SocketService
A socket transport with the policy that authorizes each address JavaScript connects to, as FetchService pairs a fetch transport with a FetchPolicy.
WebSocketAccept
What the server selected in the opening handshake.
WebSocketRequest
A client WebSocket JavaScript opened with new WebSocket(url, protocols).
WebSocketService
A WebSocket transport with the FetchPolicy that authorizes the origin of each URL JavaScript connects to, ws: and wss: counting as http: and https:, as FetchService pairs a fetch transport with it.
WorkerOptions
Configuration of the threads that own a shared application.

Enums§

Backend
Engine selection and its engine-specific configuration.
CancelledCalls
What the worker does with a call or Fetch request whose caller goes away while JavaScript runs it, such as a request the HTTP client cancels.
ChannelEvent
What one end of a channel receives: a message, a socket’s signal, or the close that ends it.
ConsoleLevel
The console method a message came from.
Error
Failures at the Rust/JavaScript execution and host-service boundaries.
Isolation
Where an App’s engine runs: in the embedder’s process, or in a child process of its own (docs/research/process-isolation.md).
Message
One message of a channel: text or binary, as WebSocket frames carry them.
Program
The executable of an isolated instance’s child process.
SecureTransport
Whether a socket speaks TLS from its start.

Traits§

ChannelService
Opens the channels of one env binding for JavaScript.
FetchTransport
A trusted, single-hop transport.
Instance
Low-level engine execution. App supplies invocation and host-service ownership. Instances are not necessarily Send; keep them on their owning worker thread.
SocketTransport
A trusted transport that opens TCP connections for JavaScript.
WebSocketTransport
A trusted transport that opens client WebSockets for JavaScript.

Functions§

channel_fn
Adapt an async Rust function to a channel service.
serve_if_child
Serve as an isolated instance when the parent started this process as one, and never return; otherwise return at once. An executable that Program names calls this first thing in main, before it reads its own arguments or writes to standard output, which carries the frames to the parent.
socket_fn
Adapt an async Rust function, such as an in-process server or a mock, to a socket transport.
transport_fn
Adapt an async Rust function, including a mock, to a host transport.
websocket_fn
Adapt an async Rust function, such as an in-process server or a mock, to a WebSocket transport.

Type Aliases§

ChannelFuture
The future of an open: Ok once the channel is open, or the error that refuses it.
FunctionFuture
The future of an async method of a Functions binding.
Request
Response
Result
TransportFuture
WebSocketFuture
The opening handshake of a client WebSocket.