pub struct ConnectionString { /* private fields */ }Expand description
Connection string parser.
Implementations§
Source§impl ConnectionString
impl ConnectionString
Sourcepub fn parse(url: &str) -> ConnectionResult<Self>
pub fn parse(url: &str) -> ConnectionResult<Self>
Parse a connection URL.
§Examples
use prax_query::connection::ConnectionString;
// PostgreSQL
let conn = ConnectionString::parse("postgres://user:pass@localhost:5432/mydb").unwrap();
// MySQL
let conn = ConnectionString::parse("mysql://user:pass@localhost/mydb").unwrap();
// SQLite
let conn = ConnectionString::parse("sqlite://./data.db").unwrap();
let conn = ConnectionString::parse("sqlite::memory:").unwrap();Sourcepub fn from_env(var: &str) -> ConnectionResult<Self>
pub fn from_env(var: &str) -> ConnectionResult<Self>
Parse from environment variable.
Sourcepub fn from_database_url() -> ConnectionResult<Self>
pub fn from_database_url() -> ConnectionResult<Self>
Parse from DATABASE_URL environment variable.
Sourcepub fn port_or_default(&self) -> Option<u16>
pub fn port_or_default(&self) -> Option<u16>
Get the port or the default for the driver.
Sourcepub fn with_param(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_param( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Build a new URL with modified parameters.
Sourcepub fn without_param(self, key: &str) -> Self
pub fn without_param(self, key: &str) -> Self
Build a new URL without a specific parameter.
Trait Implementations§
Source§impl Clone for ConnectionString
impl Clone for ConnectionString
Source§fn clone(&self) -> ConnectionString
fn clone(&self) -> ConnectionString
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 ConnectionString
impl RefUnwindSafe for ConnectionString
impl Send for ConnectionString
impl Sync for ConnectionString
impl Unpin for ConnectionString
impl UnwindSafe for ConnectionString
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