Skip to main content

Layout

Trait Layout 

Source
pub trait Layout<P: PeerId>:
    Debug
    + Send
    + Sync
    + 'static {
    // 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§

Source

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

Returns the paths peer may publish its own broadcasts under.

Source

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§

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§