Skip to main content

Session

Struct Session 

Source
pub struct Session(/* private fields */);
Expand description

The execution context for a Tokel expansion.

This struct holds the active Registry and is responsible for evaluating TokelStreams. By default, it is pre-loaded with Tokel’s standard built-in transformers, but it can be customized or strictly sandboxed as needed.

Implementations§

Source§

impl Session

Source

pub fn new() -> Self

Creates a new Session populated with the default Registry.

This includes all standard Tokel transformers (e.g., identity, case). This is the primary constructor used by standard tokel::stream! invocations.

Source

pub const fn new_with(registry: Registry) -> Self

Creates a Session using a specific, pre-configured Registry.

This is useful if you want to initialize a registry, heavily customize it, and then pass it into the session for execution.

Source

pub fn empty() -> Self

Creates a completely blank Session with an empty Registry.

This session will have no built-in transformers available. It is useful for creating strictly controlled, domain-specific token manipulation APIs where users are only allowed to use custom transformers you explicitly provide.

Source

pub const fn registry(&self) -> &Registry

Borrows the active Registry for this Session.

Source

pub const fn registry_mut(&mut self) -> &mut Registry

Mutably borrows the active Registry for this Session.

This allows you to register new custom transformers or extract state from existing ones during or after the session’s lifecycle.

Trait Implementations§

Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Session

Source§

fn default() -> Session

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.