pub struct LinksSessions<S: NamedTypeLinks, P: AccessPolicy = PermissionPolicy> { /* private fields */ }Expand description
A store served to many sessions, each with its subject (issue #149).
Without permissions every session sees and changes the whole store,
exactly as before permissions existed. With them
(with_permissions), a session sees the store
through a PermissionsDecorator of its subject, and every request is
atomic: one that fails is undone whole, the writes the store made on its
own (cascades, merges) and the names it took included, even where they
touched links the subject cannot see.
(auth: token) sets the subject of the session to the one the
Authenticator gives the token, and answers (subject: i); an unknown
token, or sessions without an authenticator, answer
(error: 'Forbidden: authentication failed').
With with_triplets the sessions read every request
as triplets (issue #152; see TripletsOperation), and permissions judge
each triplet as a whole, not the wrappers and pairs that store it.
Requests run one at a time, as &mut self already demands.
Implementations§
Source§impl<S: NamedTypeLinks> LinksSessions<S>
impl<S: NamedTypeLinks> LinksSessions<S>
Source§impl<S: NamedTypeLinks, P: AccessPolicy> LinksSessions<S, P>
impl<S: NamedTypeLinks, P: AccessPolicy> LinksSessions<S, P>
Sourcepub fn with_permissions(store: S, policy: P) -> Self
pub fn with_permissions(store: S, policy: P) -> Self
Sessions that see the store as policy lets their subjects.
Sourcepub fn with_authenticator(
self,
authenticate: impl FnMut(&mut dyn NamedTypeLinks, &str) -> Result<Option<u32>> + 'static,
) -> Self
pub fn with_authenticator( self, authenticate: impl FnMut(&mut dyn NamedTypeLinks, &str) -> Result<Option<u32>> + 'static, ) -> Self
Answers (auth: token) with authenticate.
Sourcepub fn with_subject(self, subject: u32) -> Self
pub fn with_subject(self, subject: u32) -> Self
The subject of a session before any (auth: token); the null link
(0, the default) is a guest.
Sourcepub fn with_auto_create_missing_references(self, enabled: bool) -> Self
pub fn with_auto_create_missing_references(self, enabled: bool) -> Self
Sourcepub fn with_triplets(self) -> Result<Self>
pub fn with_triplets(self) -> Result<Self>
Reads every request as triplets; the markers of the encoding are created in the store when they are missing, whatever the subject of a session may do.
Sourcepub fn ensure_triplets(&mut self) -> Result<TripletMarkers>
pub fn ensure_triplets(&mut self) -> Result<TripletMarkers>
Like with_triplets, on sessions already built.
Sourcepub fn has_triplets(&self) -> bool
pub fn has_triplets(&self) -> bool
Whether the sessions read every request as triplets.
Sourcepub fn has_permissions(&self) -> bool
pub fn has_permissions(&self) -> bool
Whether the sessions see the store through permissions.
pub fn into_inner(self) -> S
Sourcepub fn open(&mut self, subject: Option<u32>) -> SessionId
pub fn open(&mut self, subject: Option<u32>) -> SessionId
Opens a session of subject, by default the one of
with_subject.
Sourcepub fn subject(&self, session: SessionId) -> Option<u32>
pub fn subject(&self, session: SessionId) -> Option<u32>
The subject the requests of session run as, while it is open.
Sourcepub fn created(&self, session: SessionId) -> Option<&HashSet<u32>>
pub fn created(&self, session: SessionId) -> Option<&HashSet<u32>>
The links session created, while they are its own.
Sourcepub fn request(&mut self, session: SessionId, text: &str) -> String
pub fn request(&mut self, session: SessionId, text: &str) -> String
Answers a request written as LiNo text, as the text protocol does.
Sourcepub fn execute(
&mut self,
session: SessionId,
document: &[LiNo<String>],
) -> LinoDocument
pub fn execute( &mut self, session: SessionId, document: &[LiNo<String>], ) -> LinoDocument
Answers one request document of session; a session that is not
open is opened.
Sourcepub fn execute_observed(
&mut self,
session: SessionId,
document: &[LiNo<String>],
changed: &mut Vec<Change>,
) -> LinoDocument
pub fn execute_observed( &mut self, session: SessionId, document: &[LiNo<String>], changed: &mut Vec<Change>, ) -> LinoDocument
Like execute, adding the net change of every link
the request changed in the store to changed, with plain numbers:
the cascades and merges a write led to as well, even where the
subject cannot see them. A request undone for failing changed nothing.
Sourcepub fn execute_triplets_observed(
&mut self,
session: SessionId,
document: &[LiNo<String>],
changed: &mut Vec<TripletChange>,
) -> LinoDocument
pub fn execute_triplets_observed( &mut self, session: SessionId, document: &[LiNo<String>], changed: &mut Vec<TripletChange>, ) -> LinoDocument
Like execute on sessions that read requests as
triplets, adding every triplet the request changed to changed, with
plain numbers: those it took along too, even where the subject cannot
see them. A request undone for failing changed nothing.