weave-browser-engine · protocol
Source declarations, signatures and documentation for protocol.
Reviewed implementation boundary: The serve path warns but still binds when WEAVE_API_KEY is absent; the authentication check then allows requests. Configure and verify authorization before exposing a server. See /libraries/weave-browser-engine/research-server.
Source: sigil/weave/libs/weave-browser-engine/src/protocol.rs. SHA-256: a13db7a49dd80de00d7d8a29b2f9ac58ea80c6debce8b1b2742c224d811f9a12.
This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.
protocol::ProtocolResolver
A resolver that can handle a specific URL scheme.
Implement this trait to add support for a new protocol. Register the
resolver with a [ProtocolRouter] so that the fetch pipeline can
dispatch URLs to the correct backend.
#[async_trait]
pub trait ProtocolResolver: Send + Sync {
/// The URL scheme this resolver handles (e.g. `"weave"`, `"ipfs"`).
fn scheme(&self) -> &str;
/// Resolve a URL and return the raw response bytes.
async fn resolve(&self, url: &str) -> BrowserResult<Vec<u8>>;
}Source line: 32.
protocol::ProtocolRouter
Routes URLs to the correct [ProtocolResolver] based on scheme.
pub struct ProtocolRouter {
}Source line: 43.
protocol::ProtocolRouter::new
Create a new router with no resolvers registered.
pub fn new() -> Self;Source line: 49.
protocol::ProtocolRouter::register
Register a resolver for a URL scheme.
pub fn register(&mut self, resolver: Box<dyn ProtocolResolver>);Source line: 56.
protocol::ProtocolRouter::extract_scheme
Extract the scheme from a URL string, defaulting to "https".
pub fn extract_scheme(url: &str) -> String;Source line: 61.
protocol::ProtocolRouter::resolve
Resolve a URL by dispatching to the appropriate resolver.
Returns BrowserError::Protocol if no resolver matches the scheme.
pub async fn resolve(&self, url: &str) -> BrowserResult<Vec<u8>>;Source line: 70.
protocol::WeaveUrl
Parsed form of a weave:// URL.
#[derive(Debug, Clone)]
pub enum WeaveUrl {
/// Local Locus drive access: drive name + path within the drive.
Local { drive: String, path: String },
/// Remote peer access with a complete authenticated resource descriptor.
Remote {
addr: SocketAddr,
peer_did: String,
peer_auth_public_key: [u8; 32],
strand_public_key: [u8; 32],
live: bool,
},
}Source line: 95.
protocol::parse_weave_url
Parse a weave://... URL into either a local or remote form.
pub fn parse_weave_url(url: &str) -> BrowserResult<WeaveUrl>;Source line: 131.
protocol::WeaveResolver
Resolves weave:// URLs via Locus drives and remote strand replication.
For local drives, first tries the filesystem at ~/.dbrowser/sites/{drive}/{path}.
If the file does not exist on disk, falls back to the Locus in-memory store.
For remote peers, replicates a single-block strand and returns block 0.
pub struct WeaveResolver {
}Source line: 280.
protocol::WeaveResolver::new
Create a new resolver backed by a WeaveNode.
pub fn new(node: Arc<WeaveNode>) -> Self;Source line: 286.
protocol::HnsResolver
Resolves hns:// URLs via Handshake decentralized DNS.
Currently returns [BrowserError::HnsPending] — full resolution will
be implemented when Handshake DNS integration lands.
pub struct HnsResolver;Source line: 409.
protocol::HttpsResolver
Resolves standard https:// URLs via HTTP.
pub struct HttpsResolver;Source line: 432.
protocol::HttpResolver
Resolves standard http:// URLs.
pub struct HttpResolver;Source line: 461.