pub struct Client { /* private fields */ }
Expand description
Client which is used to query picodata.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn new_with_strategy<S>(
config: Config,
strategy: S,
) -> Result<Self, Error>where
S: Strategy,
pub async fn new_with_strategy<S>(
config: Config,
strategy: S,
) -> Result<Self, Error>where
S: Strategy,
Creates a new instance of picodata client with a custom strategy.
§Parameters
config
: A config for a client.strategy
: A strategy that descibes the method to pick next connection.
§Errors
- Any
Error
than manager initializer may return.
§Returns
An instance of Client
on success or an Error
if manager init did fail.
Sourcepub async fn query(
&self,
sql: &str,
params: &[&(dyn ToSql + Sync)],
) -> Result<Vec<Row>, Error>
pub async fn query( &self, sql: &str, params: &[&(dyn ToSql + Sync)], ) -> Result<Vec<Row>, Error>
Query picodata cluster.
§Parameters
sql
: A query to execute.params
: A query bind params.
§Errors
Error::Postgres
in case of failed query exeuction.Error::PostgresPool
in case of failed connection acquire.
§Returns
A vector of rows in case of success or an Error
otherwise.
Sourcepub async fn execute(
&self,
sql: &str,
params: &[&(dyn ToSql + Sync)],
) -> Result<u64, Error>
pub async fn execute( &self, sql: &str, params: &[&(dyn ToSql + Sync)], ) -> Result<u64, Error>
Execute on picodata cluster.
§Parameters
sql
: A query to execute.params
: A query bind params.
§Errors
Error::Postgres
in case of failed query exeuction.Error::PostgresPool
in case of failed connection acquire.
§Returns
A unit in case of success or an Error
otherwise.
Sourcepub async fn ping(&self) -> Result<(), Error>
pub async fn ping(&self) -> Result<(), Error>
Ping each instance of picodata cluster.
§Errors
Error::Postgres
in case of failed query exeuction.Error::PostgresPool
in case of failed connection acquire.
§Returns
A unit in case of success or an Error
otherwise.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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