BlockingSession

Struct BlockingSession 

Source
pub struct BlockingSession { /* private fields */ }
Expand description

A blocking session that waits for responses synchronously

Implementations§

Source§

impl BlockingSession

Source

pub fn command( &mut self, rql: &str, params: Option<Params>, ) -> Result<CommandResult, Error>

Send a command and wait for response

Examples found in repository?
examples/blocking_ws.rs (line 16)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7	// Connect to ReifyDB server - various ways to specify address:
8	// Using tuple (address, port):
9	let client = Client::ws(("127.0.0.1", 8090))?;
10
11	// Create a blocking session with authentication
12	let mut session = client.blocking_session(Some("mysecrettoken".to_string()))?;
13
14	// Execute a command to create a table
15	let command_result =
16		session.command("CREATE NAMESPACE test; CREATE TABLE test.users { id: INT4, name: UTF8 }", None)?;
17	println!("Command executed: {} frames returned", command_result.frames.len());
18
19	// Execute a query
20	let query_result = session.query("MAP { x: 42, y: 'hello' }", None)?;
21
22	println!("Query executed: {} frames returned", query_result.frames.len());
23
24	// Print first frame if available
25	if let Some(frame) = query_result.frames.first() {
26		println!("First frame:\n{}", frame);
27	}
28
29	Ok(())
30}
Source

pub fn query( &mut self, rql: &str, params: Option<Params>, ) -> Result<QueryResult, Error>

Send a query and wait for response

Examples found in repository?
examples/blocking_ws.rs (line 20)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7	// Connect to ReifyDB server - various ways to specify address:
8	// Using tuple (address, port):
9	let client = Client::ws(("127.0.0.1", 8090))?;
10
11	// Create a blocking session with authentication
12	let mut session = client.blocking_session(Some("mysecrettoken".to_string()))?;
13
14	// Execute a command to create a table
15	let command_result =
16		session.command("CREATE NAMESPACE test; CREATE TABLE test.users { id: INT4, name: UTF8 }", None)?;
17	println!("Command executed: {} frames returned", command_result.frames.len());
18
19	// Execute a query
20	let query_result = session.query("MAP { x: 42, y: 'hello' }", None)?;
21
22	println!("Query executed: {} frames returned", query_result.frames.len());
23
24	// Print first frame if available
25	if let Some(frame) = query_result.frames.first() {
26		println!("First frame:\n{}", frame);
27	}
28
29	Ok(())
30}
Source

pub fn is_authenticated(&self) -> bool

Check if the session is authenticated

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.