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).
Trait Implementations§
Source§impl Clone for MaExtension
impl Clone for MaExtension
Source§fn clone(&self) -> MaExtension
fn clone(&self) -> MaExtension
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MaExtension
impl Debug for MaExtension
Source§impl Default for MaExtension
impl Default for MaExtension
Source§fn default() -> MaExtension
fn default() -> MaExtension
Auto Trait Implementations§
impl Freeze for MaExtension
impl RefUnwindSafe for MaExtension
impl Send for MaExtension
impl Sync for MaExtension
impl Unpin for MaExtension
impl UnsafeUnpin for MaExtension
impl UnwindSafe for MaExtension
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more