Skip to main content

Layout

Trait Layout 

pub trait Layout<P>:
    Debug
    + Send
    + Sync
    + 'static
where P: PeerId,
{ // Required methods fn scope(&self, peer: &P) -> Prefixes; fn owner(&self, path: &str) -> Option<P>; }
Expand description

A path convention: where each peer publishes, and which peer owns a path.

The two halves agree: owner of a path that scope gives a peer names that peer or no one.

Ownership must carry down to sub-paths: every path beneath a path a peer owns is owned by that peer or by no one. A grant is a set of prefixes, so a peer that may publish at a path it owns, such as through a ticket claim, may publish beneath it too. A layout whose owner is a later segment, such as <name>/<peer>, breaks this: a claim on cam/<bob> would let Bob publish cam/<bob>/<carol>, which names Carol.

A pair (A, B) is the union of two layouts.

Required Methods§

fn scope(&self, peer: &P) -> Prefixes

Returns the paths peer may publish its own broadcasts under.

fn owner(&self, path: &str) -> Option<P>

Returns the peer that owns path, or None for a path outside the layout.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

§

impl<P, A, B> Layout<P> for (A, B)
where P: PeerId, A: Layout<P>, B: Layout<P>,

§

fn scope(&self, peer: &P) -> Prefixes

§

fn owner(&self, path: &str) -> Option<P>

§

impl<P, T> Layout<P> for Arc<T>
where P: PeerId, T: Layout<P> + ?Sized,

§

fn scope(&self, peer: &P) -> Prefixes

§

fn owner(&self, path: &str) -> Option<P>

Implementors§