pub struct HttpBlockingSession { /* private fields */ }Expand description
A blocking HTTP session that waits for responses synchronously
Implementations§
Source§impl HttpBlockingSession
impl HttpBlockingSession
Sourcepub fn new(host: &str, port: u16, token: Option<String>) -> Result<Self, Error>
pub fn new(host: &str, port: u16, token: Option<String>) -> Result<Self, Error>
Create a new blocking HTTP session
Sourcepub fn from_client(
client: HttpClient,
token: Option<String>,
) -> Result<Self, Error>
pub fn from_client( client: HttpClient, token: Option<String>, ) -> Result<Self, Error>
Create a new blocking HTTP session from an existing client
Sourcepub fn from_url(url: &str, token: Option<String>) -> Result<Self, Error>
pub fn from_url(url: &str, token: Option<String>) -> Result<Self, Error>
Create from URL (e.g., “http://localhost:8080”)
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set timeout for requests
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_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}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_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}Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Check if the session is authenticated
Auto Trait Implementations§
impl Freeze for HttpBlockingSession
impl RefUnwindSafe for HttpBlockingSession
impl Send for HttpBlockingSession
impl !Sync for HttpBlockingSession
impl Unpin for HttpBlockingSession
impl UnwindSafe for HttpBlockingSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more