pub struct HttpClient { /* private fields */ }Expand description
HTTP client implementation with worker thread
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn new<A: ToSocketAddrs>(addr: A) -> Result<Self, Box<dyn Error>>
pub fn new<A: ToSocketAddrs>(addr: A) -> Result<Self, Box<dyn Error>>
Create a new HTTP client from a socket address
Sourcepub fn from_url(url: &str) -> Result<Self, Box<dyn Error>>
pub fn from_url(url: &str) -> Result<Self, Box<dyn Error>>
Create HTTP client from URL (e.g., “http://localhost:8080”)
Sourcepub fn blocking_session(
&self,
token: Option<String>,
) -> Result<HttpBlockingSession, Error>
pub fn blocking_session( &self, token: Option<String>, ) -> Result<HttpBlockingSession, Error>
Create a blocking session
Examples found in repository?
examples/blocking_http.rs (line 10)
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 callback_session(
&self,
token: Option<String>,
) -> Result<HttpCallbackSession, Error>
pub fn callback_session( &self, token: Option<String>, ) -> Result<HttpCallbackSession, Error>
Create a callback session
Sourcepub fn channel_session(
&self,
token: Option<String>,
) -> Result<(HttpChannelSession, Receiver<HttpResponseMessage>), Error>
pub fn channel_session( &self, token: Option<String>, ) -> Result<(HttpChannelSession, Receiver<HttpResponseMessage>), Error>
Create a channel session
Trait Implementations§
Source§impl Clone for HttpClient
impl Clone for HttpClient
Source§fn clone(&self) -> HttpClient
fn clone(&self) -> HttpClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HttpClient
impl RefUnwindSafe for HttpClient
impl Send for HttpClient
impl Sync for HttpClient
impl Unpin for HttpClient
impl UnwindSafe for HttpClient
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