pub struct Gate { /* private fields */ }Expand description
The decision procedure for “may this server offer this tool”.
Implementations§
Source§impl Gate
impl Gate
Sourcepub fn new(
toolsets: BTreeSet<Toolset>,
max_tier: Tier,
unavailable: BTreeSet<Surface>,
all_tools: &[ToolMeta],
) -> Result<Self, ConfigError>
pub fn new( toolsets: BTreeSet<Toolset>, max_tier: Tier, unavailable: BTreeSet<Surface>, all_tools: &[ToolMeta], ) -> Result<Self, ConfigError>
Build a gate, refusing a configuration that would offer nothing.
all_tools is the full metadata table; the emptiness check is made
against it rather than against the toolset set, because a selection can
be non-empty and still yield no tools once the tier is applied.
Sourcepub fn unchecked(
toolsets: BTreeSet<Toolset>,
max_tier: Tier,
unavailable: BTreeSet<Surface>,
) -> Self
pub fn unchecked( toolsets: BTreeSet<Toolset>, max_tier: Tier, unavailable: BTreeSet<Surface>, ) -> Self
A gate for tests and for the tools subcommand, which must be able to
describe an empty selection rather than refuse to.
pub fn permits(&self, tool: &ToolMeta) -> bool
Sourcepub fn needs(&self, tool: &ToolMeta) -> String
pub fn needs(&self, tool: &ToolMeta) -> String
Why a tool was not offered, phrased as the flag that would offer it.
Used to build the hint on not_permitted.
pub fn toolsets(&self) -> &BTreeSet<Toolset>
Sourcepub fn offers(&self, surface: Surface) -> bool
pub fn offers(&self, surface: Surface) -> bool
Whether this session offers any tool on surface.
Both halves matter and neither alone is the answer: a surface whose
toolsets nobody selected offers nothing, and so does one that was
selected but is not there — no binary, no credential, or an operator
switch. permits asks the same two questions of one
tool; this asks them of a whole surface, for the instructions, which
have to describe what a session can actually do rather than what it was
asked for.
Sourcepub fn offered_toolsets(&self) -> impl Iterator<Item = Toolset> + '_
pub fn offered_toolsets(&self) -> impl Iterator<Item = Toolset> + '_
The selected toolsets that this session can actually serve from.
toolsets is what was asked for; this is what came of
it. Anything shown to a caller wants this one — naming a toolset whose
surface is missing tells a model that tailnet-devices is there, in a
session where every call to it is refused. That was written twice
before it was written once: the startup note and the instructions each
listed the selection, and each contradicted a sentence beside it.