pub struct MaExtension { /* private fields */ }Expand description
Fluent builder for the opaque ma: IPLD extension field on a Document.
MaExtension collects the node type, transport service strings, and any
custom IPLD fields, then produces the Ipld value ready for
Document::set_ma_extension.
The idiomatic way to populate ma: is to start from the endpoint — which
pre-populates services — and chain any additional fields:
// Endpoint pre-populates services; add type and any extras:
let ma = endpoint.ma_extension()
.kind("world");
// Build a complete, signed document in one call:
let document = bundle.build_document(ma)?;You can also build a MaExtension independently and attach it to an
existing document with Document::set_ma_extension before re-signing.
Implementations§
Source§impl MaExtension
impl MaExtension
Sourcepub fn kind(self, kind: &str) -> Self
pub fn kind(self, kind: &str) -> Self
Set ma["type"] to identify the kind of node or service.
The key name "type" follows the existing convention in the ma ecosystem.
Sourcepub fn add_service(self, service: &str) -> Self
pub fn add_service(self, service: &str) -> Self
Append one transport service string to ma["services"].
Service strings have the form /iroh/<endpoint-id>/ma/<protocol>/<version>.
Sourcepub fn services(self, services: Vec<String>) -> Self
pub fn services(self, services: Vec<String>) -> Self
Replace ma["services"] with the given list.
Use this (rather than repeated Self::add_service calls) when you
already have the full service list, e.g. from crate::MaEndpoint::services.
Sourcepub fn extra(self, key: &str, val: Ipld) -> Self
pub fn extra(self, key: &str, val: Ipld) -> Self
Set an arbitrary IPLD entry in the extension map.
Sourcepub fn build(self) -> Ipld
pub fn build(self) -> Ipld
Consume the builder and return the final Ipld value.
Returns Ipld::Null if no fields have been set (which causes
Document::set_ma_extension to clear the ma field).