pub struct GrpcConnectionAsync { /* private fields */ }Expand description
Async gRPC connection to a Hyper database (query-only).
This is the async version of GrpcConnection, designed for use with
tokio-based async applications.
§Example
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut conn = GrpcConnectionAsync::connect(
"http://localhost:7484",
"my_database.hyper"
).await?;
let arrow_data = conn.execute_query_to_arrow("SELECT * FROM users").await?;
Ok(())
}Implementations§
Source§impl GrpcConnectionAsync
impl GrpcConnectionAsync
Sourcepub async fn connect(endpoint: &str, database_path: &str) -> Result<Self>
pub async fn connect(endpoint: &str, database_path: &str) -> Result<Self>
Connects to a Hyper server via gRPC (async).
§Arguments
endpoint- The gRPC endpoint URL (e.g., “http://localhost:7484”)database_path- Path to the database to query
§Errors
Returns crate::Error::Client if the HTTP/2 channel cannot be
established (endpoint unreachable, TLS handshake failure).
Sourcepub async fn connect_with_config(config: GrpcConfig) -> Result<Self>
pub async fn connect_with_config(config: GrpcConfig) -> Result<Self>
Connects to a Hyper server via gRPC with custom configuration (async).
§Errors
Returns crate::Error::Client if the HTTP/2 channel cannot be
established with the supplied configuration.
Sourcepub async fn execute_query_to_arrow(&mut self, sql: &str) -> Result<Bytes>
pub async fn execute_query_to_arrow(&mut self, sql: &str) -> Result<Bytes>
Executes a SQL query and returns raw Arrow IPC bytes (async).
§Errors
Returns crate::Error::Client if the server rejects the query or the
HTTP/2 channel fails mid-stream.
Sourcepub async fn execute_query(&mut self, sql: &str) -> Result<GrpcQueryResult>
pub async fn execute_query(&mut self, sql: &str) -> Result<GrpcQueryResult>
Executes a SQL query and returns a structured result (async).
§Errors
Returns crate::Error::Client if the server rejects the query or the
HTTP/2 channel fails.
Sourcepub async fn cancel_query(&mut self, query_id: &str) -> Result<()>
pub async fn cancel_query(&mut self, query_id: &str) -> Result<()>
Cancels an in-flight gRPC query by its query_id (async).
See GrpcConnection::cancel_query for full semantics, including
the “Fallible by design” discussion of why this returns
Result<()> and why it is not an implementation of the
Cancellable trait. The async
variant avoids blocking the current thread; both variants route
the cancel over the same channel used for queries, carrying this
connection’s database routing and custom headers.
§Example
conn.cancel_query(query_id).await?;§Errors
Sourcepub fn config(&self) -> &GrpcConfig
pub fn config(&self) -> &GrpcConfig
Returns the gRPC configuration.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GrpcConnectionAsync
impl !RefUnwindSafe for GrpcConnectionAsync
impl Send for GrpcConnectionAsync
impl Sync for GrpcConnectionAsync
impl Unpin for GrpcConnectionAsync
impl UnsafeUnpin for GrpcConnectionAsync
impl !UnwindSafe for GrpcConnectionAsync
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request