HttpBlockingSession

Struct HttpBlockingSession 

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

A blocking HTTP session that waits for responses synchronously

Implementations§

Source§

impl HttpBlockingSession

Source

pub fn new(host: &str, port: u16, token: Option<String>) -> Result<Self, Error>

Create a new blocking HTTP session

Source

pub fn from_client( client: HttpClient, token: Option<String>, ) -> Result<Self, Error>

Create a new blocking HTTP session from an existing client

Source

pub fn from_url(url: &str, token: Option<String>) -> Result<Self, Error>

Create from URL (e.g., “http://localhost:8080”)

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Set timeout for requests

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