pub struct Dsn { /* private fields */ }Expand description
Parsed DSN (Data Source Name) for Geode connections.
Contains all connection parameters extracted from a DSN string.
Implementations§
Source§impl Dsn
impl Dsn
Sourcepub fn parse(dsn: &str) -> Result<Self>
pub fn parse(dsn: &str) -> Result<Self>
Parse a DSN string into a Dsn struct.
§Supported formats
quic://host:port?options- QUIC transport (recommended)grpc://host:port?options- gRPC transportgrpcs://host:port?options- gRPC transport with TLS forced onhost:port?options- Defaults to QUIC
§Supported options (query parameters)
tls- Enable/disable TLS (0/1/true/false, default: true)insecure,skip_verify,insecure_skip_verify- Skip TLS verificationpage_size- Results page size (default: 1000)client_nameorhello_name- Client nameclient_versionorhello_ver- Client versionconformance- GQL conformance levelusernameoruser- Authentication usernamepasswordorpass- Authentication passwordcaorca_cert- Path to CA certificatecertorclient_cert- Path to client certificate (mTLS)keyorclient_key- Path to client key (mTLS)server_name- SNI server nameconnect_timeoutortimeout- Connection timeout in seconds
§Errors
Returns Error::InvalidDsn if:
- DSN is empty
- Scheme is unsupported
- Host is missing
- Port is invalid
§Examples
use geode_client::dsn::Dsn;
let dsn = Dsn::parse("quic://localhost:3141").unwrap();
let dsn = Dsn::parse("grpc://127.0.0.1:50051?tls=0").unwrap();
let dsn = Dsn::parse("grpc://[::1]:50051").unwrap();Sourcepub fn tls_enabled(&self) -> bool
pub fn tls_enabled(&self) -> bool
Check if TLS is enabled.
Sourcepub fn skip_verify(&self) -> bool
pub fn skip_verify(&self) -> bool
Check if TLS verification should be skipped.
Sourcepub fn client_name(&self) -> &str
pub fn client_name(&self) -> &str
Get the client name.
Sourcepub fn client_version(&self) -> &str
pub fn client_version(&self) -> &str
Get the client version.
Sourcepub fn conformance(&self) -> &str
pub fn conformance(&self) -> &str
Get the conformance level.
Sourcepub fn client_cert(&self) -> Option<&str>
pub fn client_cert(&self) -> Option<&str>
Get the client certificate path if specified.
Sourcepub fn client_key(&self) -> Option<&str>
pub fn client_key(&self) -> Option<&str>
Get the client key path if specified.
Sourcepub fn server_name(&self) -> Option<&str>
pub fn server_name(&self) -> Option<&str>
Get the SNI server name if specified.
Sourcepub fn connect_timeout_secs(&self) -> Option<u64>
pub fn connect_timeout_secs(&self) -> Option<u64>
Get the connection timeout in seconds if specified.
Sourcepub fn to_dsn(&self) -> String
pub fn to_dsn(&self) -> String
Format this DSN back into a connection-string form.
Mirrors the Go reference client’s Config.FormatDSN: emits
scheme://userinfo@host:port?onlyNonDefaultParams. Only parameters
that differ from the defaults are emitted, query keys are sorted for
determinism, and userinfo/values are percent-encoded.
Credentials follow Go’s rules: a username with a password becomes
user:pass@, a username alone becomes user@, and a password
without a username falls back to a pass= query parameter (since
userinfo cannot carry a password-only credential).
The result round-trips through Dsn::parse.
§Example
use geode_client::dsn::Dsn;
let dsn = Dsn::parse("quic://localhost:3141?page_size=500").unwrap();
let s = dsn.to_dsn();
assert_eq!(Dsn::parse(&s).unwrap(), dsn);Trait Implementations§
impl StructuralPartialEq for Dsn
Auto Trait Implementations§
impl Freeze for Dsn
impl RefUnwindSafe for Dsn
impl Send for Dsn
impl Sync for Dsn
impl Unpin for Dsn
impl UnsafeUnpin for Dsn
impl UnwindSafe for Dsn
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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