pub trait MysqlShim<W: Read + Write> {
type Error: From<Error>;
// Required methods
fn on_prepare(
&mut self,
query: &str,
info: StatementMetaWriter<'_, W>
) -> Result<(), Self::Error>;
fn on_execute(
&mut self,
id: u32,
params: ParamParser<'_>,
results: QueryResultWriter<'_, W>
) -> Result<(), Self::Error>;
fn on_close(&mut self, stmt: u32);
fn on_query(
&mut self,
query: &str,
results: QueryResultWriter<'_, W>
) -> Result<(), Self::Error>;
// Provided methods
fn on_init(
&mut self,
_: &str,
_: InitWriter<'_, W>
) -> Result<(), Self::Error> { ... }
fn tls_config(&self) -> Option<Arc<ServerConfig>> { ... }
fn after_authentication(
&mut self,
_context: &AuthenticationContext<'_>
) -> Result<(), Self::Error> { ... }
}
Expand description
Implementors of this trait can be used to drive a MySQL-compatible database backend.
Required Associated Types§
Required Methods§
sourcefn on_prepare(
&mut self,
query: &str,
info: StatementMetaWriter<'_, W>
) -> Result<(), Self::Error>
fn on_prepare( &mut self, query: &str, info: StatementMetaWriter<'_, W> ) -> Result<(), Self::Error>
Called when the client issues a request to prepare query
for later execution.
The provided StatementMetaWriter
should be used to
notify the client of the statement id assigned to the prepared statement, as well as to
give metadata about the types of parameters and returned columns.
sourcefn on_execute(
&mut self,
id: u32,
params: ParamParser<'_>,
results: QueryResultWriter<'_, W>
) -> Result<(), Self::Error>
fn on_execute( &mut self, id: u32, params: ParamParser<'_>, results: QueryResultWriter<'_, W> ) -> Result<(), Self::Error>
Called when the client executes a previously prepared statement.
Any parameters included with the client’s command is given in params
.
A response to the query should be given using the provided
QueryResultWriter
.
sourcefn on_close(&mut self, stmt: u32)
fn on_close(&mut self, stmt: u32)
Called when the client wishes to deallocate resources associated with a previously prepared statement.
sourcefn on_query(
&mut self,
query: &str,
results: QueryResultWriter<'_, W>
) -> Result<(), Self::Error>
fn on_query( &mut self, query: &str, results: QueryResultWriter<'_, W> ) -> Result<(), Self::Error>
Called when the client issues a query for immediate execution.
Results should be returned using the given
QueryResultWriter
.
Provided Methods§
sourcefn on_init(&mut self, _: &str, _: InitWriter<'_, W>) -> Result<(), Self::Error>
fn on_init(&mut self, _: &str, _: InitWriter<'_, W>) -> Result<(), Self::Error>
Called when client switches database.
sourcefn tls_config(&self) -> Option<Arc<ServerConfig>>
fn tls_config(&self) -> Option<Arc<ServerConfig>>
Provides the TLS configuration, if we want to support TLS.
sourcefn after_authentication(
&mut self,
_context: &AuthenticationContext<'_>
) -> Result<(), Self::Error>
fn after_authentication( &mut self, _context: &AuthenticationContext<'_> ) -> Result<(), Self::Error>
Called after successful authentication (including TLS if applicable) passing relevant information to allow additional logic in the MySqlShim implementation.