Skip to main content

MysqlConn

Struct MysqlConn 

Source
pub struct MysqlConn(pub Conn);
Expand description

A wrapper around mysql_async::Conn that implements sql_composer::driver::ComposerConnectionAsync.

Dereferences to the inner mysql_async::Conn, so all native async methods are available directly.

Tuple Fields§

§0: Conn

Implementations§

Source§

impl MysqlConn

Source

pub fn from_conn(conn: Conn) -> Self

Wrap an existing mysql_async::Conn.

Methods from Deref<Target = Conn>§

Source

pub fn id(&self) -> u32

Returns connection identifier.

Source

pub fn last_insert_id(&self) -> Option<u64>

Returns the ID generated by a query (usually INSERT) on a table with a column having the AUTO_INCREMENT attribute. Returns None if there was no previous query on the connection or if the query did not update an AUTO_INCREMENT value.

Source

pub fn affected_rows(&self) -> u64

Returns the number of rows affected by the last INSERT, UPDATE, REPLACE or DELETE query.

Source

pub fn info(&self) -> Cow<'_, str>

Text information, as reported by the server in the last OK packet, or an empty string.

Source

pub fn get_warnings(&self) -> u16

Number of warnings, as reported by the server in the last OK packet, or 0.

Source

pub fn last_ok_packet(&self) -> Option<&OkPacket<'static>>

Returns a reference to the last OK packet.

Source

pub fn reset_connection(&mut self, reset_connection: bool)

Turns on/off automatic connection reset (see crate::PoolOpts::with_reset_connection).

Only makes sense for pooled connections.

Source

pub fn server_version(&self) -> (u16, u16, u16)

Returns server version.

Source

pub fn opts(&self) -> &Opts

Returns connection options.

Source

pub fn set_infile_handler<T>(&mut self, handler: T)
where T: Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Send>>, Error>> + Send + Sync + 'static,

Setup local LOCAL INFILE handler (see “LOCAL INFILE Handlers” section of the crate-level docs).

It’ll overwrite existing local handler, if any.

Source

pub async fn reset(&mut self) -> Result<bool, Error>

Executes COM_RESET_CONNECTION.

Returns false if command is not supported (requires MySql >5.7.2, MariaDb >10.2.3). For older versions consider using Conn::change_user.

Source

pub async fn change_user(&mut self, opts: ChangeUserOpts) -> Result<(), Error>

Executes COM_CHANGE_USER.

This might be used as an older and slower alternative to COM_RESET_CONNECTION that works on MySql prior to 5.7.3 (MariaDb prior ot 10.2.4).

§Note
  • Using non-default opts for a pooled connection is discouraging.
  • Connection options will be permanently updated.
Source

pub async fn start_transaction( &mut self, options: TxOpts, ) -> Result<Transaction<'_>, Error>

Starts a transaction.

Trait Implementations§

Source§

impl ComposerConnectionAsync for MysqlConn

Available on crate feature async only.
Source§

type Value = Value

The database-specific value type for bind parameters.
Source§

type Statement = String

The composed SQL string.
Source§

type Error = AsyncError

The error type for this driver.
Source§

async fn compose( &self, composer: &Composer, template: &Template, values: BTreeMap<String, Vec<Self::Value>>, ) -> Result<(String, Vec<Self::Value>), AsyncError>

Compose a template with bind values asynchronously.
Source§

impl Deref for MysqlConn

Available on crate feature async only.
Source§

type Target = Conn

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for MysqlConn

Available on crate feature async only.
Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V