pub struct BlockingSession { /* private fields */ }Expand description
A blocking session that waits for responses synchronously
Implementations§
Source§impl BlockingSession
impl BlockingSession
Sourcepub fn command(
&mut self,
rql: &str,
params: Option<Params>,
) -> Result<CommandResult, Error>
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}Sourcepub fn query(
&mut self,
rql: &str,
params: Option<Params>,
) -> Result<QueryResult, Error>
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}Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Check if the session is authenticated