Skip to main content

SharedSession

Type Alias SharedSession 

Source
pub type SharedSession = Session<'static, Arc<Engine>>;
Expand description

A Session that holds its engine by Arc: 'static + Send, with no lifetime to thread through the caller’s types. Build one with SharedSession::new or SharedSession::from(arc).

use std::sync::Arc;
use datalogic_rs::{Engine, SharedSession};

let engine = Arc::new(Engine::new());
let logic = engine.compile(r#"{"var": "x"}"#).unwrap();
let mut session = SharedSession::new(engine);
let handle = std::thread::spawn(move || session.eval_str(&logic, r#"{"x": 1}"#).unwrap());
assert_eq!(handle.join().unwrap(), "1");

Aliased Type§

pub struct SharedSession { /* private fields */ }

Implementations§

Source§

impl SharedSession

Source

pub fn new(engine: Arc<Engine>) -> Self

A session over a shared engine. The session keeps the engine alive.

Trait Implementations§

Source§

impl From<Arc<Engine>> for SharedSession

Source§

fn from(engine: Arc<Engine>) -> Self

Converts to this type from the input type.