pub struct AccessControl { /* private fields */ }Expand description
Per-rider access control: which stops the rider is allowed to visit.
When absent from a rider entity, the rider has unrestricted access.
When present, can_access returns true either
when the queried stop is in allowed_stops
or when the set is empty — an empty set means “no restriction”
(matches AccessControl::default() and the principle-of-least-
surprise that an empty allowlist shouldn’t silently block all access).
To explicitly block all stops, use a sentinel set or a dedicated
no-access wrapper. (#289)
Implementations§
Source§impl AccessControl
impl AccessControl
Sourcepub const fn new(allowed_stops: HashSet<EntityId>) -> Self
pub const fn new(allowed_stops: HashSet<EntityId>) -> Self
Create a new access control with the given set of allowed stops. Pass an empty set for “no restriction” (unrestricted access).
Sourcepub fn can_access(&self, stop: EntityId) -> bool
pub fn can_access(&self, stop: EntityId) -> bool
Check if the rider can access the given stop.
An empty allowed_stops set is treated as “no restriction” —
can_access returns true for any stop. A non-empty set is an
allowlist; stop must be a member.
Sourcepub const fn allowed_stops(&self) -> &HashSet<EntityId>
pub const fn allowed_stops(&self) -> &HashSet<EntityId>
The set of allowed stop entity IDs. Empty means unrestricted.
Trait Implementations§
Source§impl Clone for AccessControl
impl Clone for AccessControl
Source§fn clone(&self) -> AccessControl
fn clone(&self) -> AccessControl
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more