Skip to main content

LinksSessions

Struct LinksSessions 

Source
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>

Source

pub fn new(store: S) -> Self

Sessions that see and change the whole store.

Source§

impl<S: NamedTypeLinks, P: AccessPolicy> LinksSessions<S, P>

Source

pub fn with_permissions(store: S, policy: P) -> Self

Sessions that see the store as policy lets their subjects.

Source

pub fn with_authenticator( self, authenticate: impl FnMut(&mut dyn NamedTypeLinks, &str) -> Result<Option<u32>> + 'static, ) -> Self

Answers (auth: token) with authenticate.

Source

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.

Source

pub fn with_auto_create_missing_references(self, enabled: bool) -> Self

Source

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.

Source

pub fn ensure_triplets(&mut self) -> Result<TripletMarkers>

Like with_triplets, on sessions already built.

Source

pub fn has_triplets(&self) -> bool

Whether the sessions read every request as triplets.

Source

pub fn has_permissions(&self) -> bool

Whether the sessions see the store through permissions.

Source

pub fn store(&self) -> &S

The store.

Source

pub fn store_mut(&mut self) -> &mut S

The store, to read or write it as no session.

Source

pub fn policy(&self) -> Option<&P>

The policy, when there are permissions.

Source

pub fn into_inner(self) -> S

Source

pub fn open(&mut self, subject: Option<u32>) -> SessionId

Opens a session of subject, by default the one of with_subject.

Source

pub fn close(&mut self, session: SessionId)

Closes a session.

Source

pub fn sessions(&self) -> Vec<SessionId>

The sessions that are open.

Source

pub fn subject(&self, session: SessionId) -> Option<u32>

The subject the requests of session run as, while it is open.

Source

pub fn created(&self, session: SessionId) -> Option<&HashSet<u32>>

The links session created, while they are its own.

Source

pub fn request(&mut self, session: SessionId, text: &str) -> String

Answers a request written as LiNo text, as the text protocol does.

Source

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.

Source

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.

Source

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.

Source

pub fn can_read(&mut self, session: SessionId, link: &Link) -> bool

Whether the subject of session may read link: always, without permissions; a session that is not open is a guest.

Auto Trait Implementations§

§

impl<S, P = PermissionPolicy> !RefUnwindSafe for LinksSessions<S, P>

§

impl<S, P = PermissionPolicy> !Send for LinksSessions<S, P>

§

impl<S, P = PermissionPolicy> !Sync for LinksSessions<S, P>

§

impl<S, P = PermissionPolicy> !UnwindSafe for LinksSessions<S, P>

§

impl<S, P> Freeze for LinksSessions<S, P>
where S: Freeze, P: Freeze,

§

impl<S, P> Unpin for LinksSessions<S, P>
where S: Unpin, P: Unpin,

§

impl<S, P> UnsafeUnpin for LinksSessions<S, P>
where S: UnsafeUnpin, P: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.