Skip to main content

PackageHandler

Trait PackageHandler 

Source
pub trait PackageHandler {
    // Required methods
    fn manifest(&self) -> WireManifest;
    fn fetch(
        &self,
        store: &dyn BlobStore,
        id: &WireArtifactId,
    ) -> Result<Option<Vec<u8>>, String>;
    fn put(
        &self,
        store: &dyn BlobStore,
        id: &WireArtifactId,
        data: &[u8],
    ) -> Result<(), String>;
    fn list(
        &self,
        store: &dyn BlobStore,
        name_filter: Option<&str>,
        limit: usize,
    ) -> Result<Vec<WireArtifactEntry>, String>;
    fn coordinate_for_path(&self, suburl: &str) -> Option<WireArtifactId>;
    fn http(
        &self,
        store: &dyn BlobStore,
        req: &WireHttpRequest,
    ) -> Result<WireHttpResponse, String>;
}
Expand description

The format logic of one package handler. Everything here is pure over a BlobStore, so the single implementation compiles for the host and for wasm32-unknown-unknown unchanged. A handler crate implements this once; the wasm crate beside it adds no logic, only the ABI shim.

Required Methods§

Source

fn manifest(&self) -> WireManifest

Identity, reported to the host at load.

Source

fn fetch( &self, store: &dyn BlobStore, id: &WireArtifactId, ) -> Result<Option<Vec<u8>>, String>

Fetch one coordinate’s bytes.

Source

fn put( &self, store: &dyn BlobStore, id: &WireArtifactId, data: &[u8], ) -> Result<(), String>

Store one coordinate’s bytes.

Source

fn list( &self, store: &dyn BlobStore, name_filter: Option<&str>, limit: usize, ) -> Result<Vec<WireArtifactEntry>, String>

Enumerate held artifacts, filtered by a substring of the name.

Source

fn coordinate_for_path(&self, suburl: &str) -> Option<WireArtifactId>

Map a raw HTTP suburl back to a coordinate — the inverse of the path this handler serves from. Pure: it must not touch the store, because the serve-time quarantine gate calls it on every request.

Source

fn http( &self, store: &dyn BlobStore, req: &WireHttpRequest, ) -> Result<WireHttpResponse, String>

Answer one HTTP request against this handler’s own path scheme.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§