Skip to main content

Module registry

Module registry 

Source
Expand description

HTTP client for the Memstead registry (memstead.io).

Thin wrapper around reqwest::blocking that knows the two routes the CLI consumes (POST /api/publish, GET /api/mem/...) plus the typed error envelope (ApiError) the registry emits.

Structs§

ApiErrorBody
The decoded wire-level error shape the registry returns on any non-2xx. variant is present only for validation_failed responses; other error kinds leave it None.
DenylistResponse
Outcome of a successful POST /api/admin/denylist.
DomainSignature
A per-publish domain-authority signature, presented in request headers for a <domain>:<handle> publish. The CLI builds this from the domain’s stored key (see crate::auth::domain_key); the registry verifies it against the hosted proof manifest.
PublishResponse
Outcome of a successful /api/publish POST.
UnpublishResponse
Outcome of a successful DELETE /api/mem/<scope>/<name>.

Enums§

DownloadError
PublishError

Constants§

ACCEPTED_TERMS_VERSION
The publisher-terms version the CLI accepts on publish. Running memstead publish is a deliberate act, so the CLI accepts the current terms on the publisher’s behalf by sending this version. Must track the registry’s CURRENT_TERMS_VERSION; a mismatch surfaces as a terms_not_accepted refusal naming the version, telling the user to update.
DEFAULT_REGISTRY
Default registry when no --registry / MEMSTEAD_REGISTRY is set.

Functions§

admin_denylist
Admin-only: add a canonical-bytes SHA-256 to the content deny-list so those exact bytes can never be published. Refuses non-admins with 403.
admin_takedown
Admin-only takedown of a published mem: same DELETE route as unpublish, but with the x-memstead-takedown header carrying the statement-of-reasons notice reference. The server selects the takedown path (deny-list the bytes, tombstone, burn the name) instead of an ordinary hard-delete, and refuses non-admins with 403.
build_http
Shared HTTP client. 30 s timeout is comfortable for the 2 MB cap times a slow upstream — GitHub API is also cheap to tolerate.
download_mem
GET a sealed .mem archive from the registry, streaming into dest_path. Returns the number of bytes written.
parse_ref
Parse a registry ref <scope>/<name> in one of the three scope forms (github:<handle>/<name>, <domain>:<handle>/<name>, or a bare <handle>/<name>). The legacy @scope/name syntax is rejected by the caller before this is reached. Returns None for anything that is not a valid registry ref (e.g. a local file path), so install can fall back to a local install.
publish
POST a sealed .mem archive to /api/publish. Returns the parsed success body or a typed ApiErrorBody on any non-2xx.
registry_base
Resolve the registry base URL in priority order: CLI flag → MEMSTEAD_REGISTRY env → DEFAULT_REGISTRY. Trailing slashes are stripped so callers can unconditionally append route segments.
registry_host
Extract the hostname for credentials keying. Falls back to the full URL on parse failure so nothing silently collides.
unpublish
DELETE a mem from the registry. Same auth + error envelope as publish, so reuse PublishError for the failure shape.