Expand description
Serve shared fetchlet applications over HTTP.
FetchletService is a Tower service over http 1 types and is always
available. The hyper, axum and actix features add thin integrations
for those servers; with axum, Server serves one build behind Rust
routes in a few lines. Artifact reads the output of fetchlet/build, and
AssetService serves its client assets from an AssetArchive.
WebviewResponder answers a webview’s custom URI scheme, such as
Tauri’s, in-process with any of these services.
The dev-reload feature adds DevReload, which serves an artifact while a
build tool rewrites it, and the vite-dev feature adds ViteDev, which
runs the server module from a Vite dev server through Vite’s module runner.
The JavaScript engine is chosen on the fetchlet crate, and the
transports of JavaScript’s outbound sockets and WebSockets are in
fetchlet-net.
Macros§
- include_
artifact - Embed the artifact in
$directoryin the binary: itsfetchlet.json,server.jsandassets.flpk, whichfetchlet/buildwrites witharchiveArtifactAssets.$directoryis a string literal or a macro such asconcat!orenv!that expands to one, and is resolved asinclude_bytes!resolves paths, relative to the file that calls it.
Structs§
- Actix
Service - An actix-web handler for a shared fetchlet application.
- Artifact
- A build output of
fetchlet/build:fetchlet.json, the server module and the client assets. - Asset
- One served path of an
AssetArchive. - Asset
Archive - Client assets packed by
writeAssetArchiveinfetchlet/build. - Asset
Service - A Tower service that answers GET and HEAD from an
AssetArchiveand passes every other request tofallback. - Axum
Service FetchletServicewith axum’s request and response types.- DevBody
- The response body of a
DevService: the generation’s body, that body followed by the reload script, or the reload poll’s answer. - DevReload
- Serves an artifact while it is rebuilt, for development.
- DevReload
Builder - Settings for
DevReload. - DevService
- The Tower service of a
DevReload. - Fetchlet
Service - A cloneable Tower service for a shared fetchlet application.
- Generation
- What one build of the artifact serves: a service and the applications it uses, which are shut down when a later build replaces them.
- Hyper
Connection HyperServicefor one connection, recording its peer address.- Hyper
Service FetchletServiceas a hyper 1 service.- Peer
Addr - The peer address of the connection a request arrived on.
- Public
Origin - The configured public scheme and authority of incoming requests.
- Reloads
- Reports each new generation of a
DevReload, for hosts that reload their views themselves. - Request
Context - Default metadata passed as the Fetch entry’s second argument.
- Server
- An axum server for one
fetchlet/buildartifact: Rust routes first, then the artifact’s client assets, then the application. - ViteDev
- A connection to a Vite dev server running
fetchlet/vite, for development without a build. - Vite
Proxy - The Tower service of
ViteDev::proxy. - Webview
- A
Serverstarted for a webview’s custom URI scheme: answers its requests and holds the application. Clones share it. - Webview
Responder - Answers a webview’s custom-protocol requests in-process with an HTTP
service, such as an axum
Routeror aFetchletService. - Webview
Scheme - A custom URI scheme a webview loads the application from, such as one
registered with Tauri’s
register_asynchronous_uri_scheme_protocol.
Enums§
- Artifact
Error - A failure to read an artifact.
- Asset
Archive Error - A failure to read an asset archive.
- Asset
Future - The future of an
AssetServicecall. - Error
- Conversion and execution failures available to the Rust error callback.
- Reload
Error - A failure while loading a new build. The previous generation keeps serving.
- Server
Error - A failure to start serving.
- Vite
DevError - A failure to reach the Vite dev server or to read what it served.
Constants§
- RELOAD_
POLL_ PATH - The path the reload script polls for a new generation.
- RELOAD_
SCRIPT_ PATH - The path of the reload script that HTML pages link to.
- VITE_
BINDING - The binding name through which the development artifact reaches the Vite
dev server;
fetchlet/vite/dev-runnerreads the same name. - VITE_
URL_ VARIABLE - The environment variable that names a Vite dev server to run from, read
when the
vite-devfeature is enabled.
Functions§
- artifact_
router - A router that serves the artifact’s client assets and passes every other request to the application.
- connect_
info - The client address recorded by
into_make_service_with_connect_info. - peer_
addr - The client address recorded by
HyperService::connection. - router_
transport - Serve host fetches with an axum
Router. - service_
transport - Serve host fetches with a Tower service, such as an axum
Router.
Type Aliases§
- Asset
Body - The body of an
AssetServiceresponse: an asset, or the fallback’s body. - BoxError
- Vite
Body - The response body of a
ViteProxy: Vite’s or the app’s.