Skip to main content

Crate errand

Crate errand 

Source
Expand description

§errand

Async small-web (“smolweb”) transport in one scheme-routed call. errand fetches a URL over a small-web protocol and hands back the raw bytes, a normalized Status, and a MIME hint. It speaks gemini (TLS, TOFU), gopher, finger, spartan, nex, guppy, and titan, routed by scheme.

Alongside the read schemes sit two write companions: titan_upload (gemini’s upload sibling) and misfin_send (gemini-style mail delivery, with a caller-supplied client certificate). These are not fetchable schemes, so they are direct calls, not part of fetch.

It does not speak HTTP, on purpose. HTTP is already well served (reqwest), and a browser-extension host gets HTTP from the browser. errand fills the gap those leave: the protocols of the small web, with no large dependency cone.

let page = errand::fetch("gemini://geminiprotocol.net/").await?;
if page.status == errand::Status::Success {
    println!("{} bytes of {}", page.body.len(), page.mime().unwrap_or("?"));
}

Modules§

parse
Smolweb document parsers: model-free, host-agnostic per-format parsers that turn a protocol’s bytes into a small AST. Separate from the transport above; a consumer composes them (fetch, then parse) or parses a local file with no fetch at all. The dep-free parsers (gemtext, gopher, nex, …) are always available; only the feed (RSS/Atom) parser, which needs an XML reader, sits behind the parse-feed feature. See parse for the per-format submodules. Smolweb document parsers — the format structure of the protocols errand’s transport speaks, as a model-free, host-agnostic layer.

Structs§

ClientIdentity
A client identity for a misfin send: the certificate chain + private key, in DER, supplied by the caller. The leaf comes first; further chain certificates (the spec’s mailbox-signed-by-host setup) follow. The key must be PKCS#8 (the format Mere’s vault-derived identities produce).
InMemoryTofu
A process-lifetime, in-memory TofuStore. Pins last as long as the store; the right choice for a session, a test, or any host that does not need pins to survive a restart.
PermissiveTofu
The accept-any store: never reports a pin, never records one. With it installed (the default when none is set), every TLS handshake is treated as a first contact and accepted — the permissive TOFU errand used before pinning existed.
Response
One smolweb response: a normalized Status, the protocol meta line (a MIME type, prompt, redirect target, or reason depending on the status), and the raw body bytes.
Url
A parsed URL record.

Enums§

Error
A transport error.
Scheme
A small-web scheme errand can route.
Status
A normalized cross-protocol response status. The protocol’s own numeric code, where it has one (gemini, spartan, guppy, titan), is preserved in Response::raw_status.

Constants§

MISFIN_PORT
Misfin’s well-known port.

Traits§

TofuStore
A store of pinned leaf-certificate fingerprints, keyed by host.

Functions§

fetch
Fetch url over its smolweb scheme. Convenience wrapper over fetch_url that parses the string first.
fetch_timeout
Fetch url with a per-request timeout. Returns Error::Timeout if the fetch does not complete within timeout.
fetch_url
Fetch an already-parsed url, routing by scheme. The body is read in full (smolweb servers close the connection when the response ends).
fetch_url_timeout
Fetch an already-parsed url with a per-request timeout. Returns Error::Timeout if the fetch does not complete within timeout.
misfin_send
Send message to a misfin recipient (misfin://mailbox@host[:port]), presenting identity as the client certificate. Returns the recipient host’s gemini-format Response (2x delivered, 3x redirect, 4x/5x failure, 6x certificate). errand does not follow misfin redirects; the caller decides.
set_trust_store
Install the process-wide TofuStore errand’s TLS schemes pin against.
titan_upload
Upload body to url with the given mime type and optional token. Returns the server’s Gemini-format response.