pub struct Client { /* private fields */ }Expand description
A Geode database client using QUIC transport.
Use the builder pattern to configure the client, then call connect
to establish a connection.
§Example
use geode_client::Client;
let client = Client::new("127.0.0.1", 3141)
.skip_verify(true) // Development only!
.page_size(500)
.client_name("my-app");
let mut conn = client.connect().await?;
let (page, _) = conn.query("RETURN 1 AS x").await?;
conn.close()?;Implementations§
Source§impl Client
impl Client
Sourcepub fn new(host: impl Into<String>, port: u16) -> Self
pub fn new(host: impl Into<String>, port: u16) -> Self
Create a new QUIC client for the specified host and port.
§Arguments
host- The server hostname or IP addressport- The server port (typically 3141 for Geode)
§Example
use geode_client::Client;
let client = Client::new("localhost", 3141);
let client = Client::new("192.168.1.100", 8443);
let client = Client::new(String::from("geode.example.com"), 3141);Sourcepub fn from_dsn(dsn: &str) -> Result<Self>
pub fn from_dsn(dsn: &str) -> Result<Self>
Create a new client from a DSN (Data Source Name) string.
Supported formats:
host:port- Basic connectionhost:port?options- With query parametersgeode://host:port?options- URL formatgeode://user:pass@host:port?options- With authentication
Supported options:
page_size- Results page size (default: 1000)hello_name- Client name (default: “geode-rust-quinn”)hello_ver- Client version (default: “0.1.0”)conformance- GQL conformance level (default: “min”)insecure- Skip TLS verification (true/false, default: false)
§Example
use geode_client::Client;
// Simple DSN
let client = Client::from_dsn("localhost:3141").unwrap();
// With options
let client = Client::from_dsn("localhost:3141?insecure=true&page_size=500").unwrap();
// URL format with auth
let client = Client::from_dsn("geode://admin:secret@localhost:3141?insecure=true").unwrap();Sourcepub fn skip_verify(self, skip: bool) -> Self
pub fn skip_verify(self, skip: bool) -> Self
Sourcepub fn page_size(self, size: usize) -> Self
pub fn page_size(self, size: usize) -> Self
Set the page size for query results.
Controls how many rows are returned per page when fetching results. Larger values reduce round-trips but use more memory.
§Arguments
size- Number of rows per page (default: 1000)
Sourcepub fn client_name(self, name: impl Into<String>) -> Self
pub fn client_name(self, name: impl Into<String>) -> Self
Set the client name sent to the server.
This appears in server logs and can help with debugging.
§Arguments
name- Client application name (default: “geode-rust-quinn”)
Sourcepub fn client_version(self, version: impl Into<String>) -> Self
pub fn client_version(self, version: impl Into<String>) -> Self
Set the client version sent to the server.
§Arguments
version- Client version string (default: “0.1.0”)
Sourcepub fn conformance(self, level: impl Into<String>) -> Self
pub fn conformance(self, level: impl Into<String>) -> Self
Sourcepub async fn connect(&self) -> Result<Connection>
pub async fn connect(&self) -> Result<Connection>
Connect to the Geode database.
Establishes a QUIC connection to the server, performs the TLS handshake, and sends the initial HELLO message.
§Returns
A Connection that can be used to execute queries.
§Errors
Returns an error if:
- The hostname cannot be resolved
- The connection cannot be established
- TLS verification fails (unless
skip_verifyis true) - The HELLO handshake fails
§Example
let client = Client::new("localhost", 3141).skip_verify(true);
let mut conn = client.connect().await?;
// Use connection...
conn.close()?;