Viewer

Trait Viewer 

Source
pub trait Viewer {
    // Required method
    fn actor(&self) -> &str;

    // Provided methods
    fn claims(&self) -> &BTreeMap<Arc<str>, Arc<str>> { ... }
    fn path(&self) -> &str { ... }
}
Expand description

Who a view is rendered for, or a command proposed by.

A trait rather than a type because the two sources of one are genuinely different and both are legitimate. A connection supplies a beck_rt::identity::Actor, which only that module’s Identity::verify can make and which carries the claims the provider verified — the impl for it is there rather than here, because the credential is the host’s to check. A name supplies itself: beck test’s when session("ana") sends …, the differential harness, a benchmark, a client of the playground’s tab server — none of them is a connection, so none of them has a credential to check, and each of them has no claims because there was nobody to make any.

One code path either way, which is the point: a &str and an Actor reach the same Session constructor, so a claim cannot appear in one render path and not another.

Required Methods§

Source

fn actor(&self) -> &str

Provided Methods§

Source

fn claims(&self) -> &BTreeMap<Arc<str>, Arc<str>>

Empty unless a provider verified them.

Source

fn path(&self) -> &str

Where this viewer is — the route, as the browser last stated it.

Defaulted rather than required, and the default is the application’s root: a viewer that is not a browser has no route, and beck test, the differential harness and every benchmark are exactly that. The one implementation that overrides it is the subscription’s, because a socket is the only thing that can be told the route changed.

Implementations on Foreign Types§

Source§

impl Viewer for str

Source§

fn actor(&self) -> &str

Source§

impl Viewer for String

Source§

fn actor(&self) -> &str

Source§

impl Viewer for Arc<str>

Source§

fn actor(&self) -> &str

Source§

impl<T> Viewer for &T
where T: Viewer + ?Sized,

So a caller holding a &&str — which is what iterating a [&str] gives — needs no ceremony.

Source§

fn actor(&self) -> &str

Source§

fn claims(&self) -> &BTreeMap<Arc<str>, Arc<str>>

Source§

fn path(&self) -> &str

Implementors§

Source§

impl Viewer for Actor

An actor is who a view is rendered for and who a command is proposed by.

The trait is beck_host::program::Viewer and this impl is here rather than beside it, because what distinguishes an Actor from the other things that can be a viewer is precisely that a credential was checked — and checking credentials is the host’s job, not the program’s.

Source§

impl<W> Viewer for At<W>
where W: Viewer,