v4.3.15
- The previous interceptor can decide whether to allow the next interceptor to continue execution
- change Intercept to
pub trait Intercept: Send + Sync + Debug {
fn name(&self) -> &str {
std::any::type_name::<Self>()
}
/// task_id maybe is conn_id or tx_id,
/// is_prepared_sql = !args.is_empty(),
/// if return Ok(false) will be return data. return Ok(true) will run next
fn before(
&self,
_task_id: i64,
_rb: &dyn Executor,
_sql: &mut String,
_args: &mut Vec<Value>,
_result: ResultType<&mut Result<ExecResult, Error>, &mut Result<Vec<Value>, Error>>,
) -> Result<bool, Error> {
Ok(true)
}
/// task_id maybe is conn_id or tx_id,
/// is_prepared_sql = !args.is_empty(),
/// if return Ok(false) will be return data. return Ok(true) will run next
fn after(
&self,
_task_id: i64,
_rb: &dyn Executor,
_sql: &mut String,
_args: &mut Vec<Value>,
_result: ResultType<&mut Result<ExecResult, Error>, &mut Result<Vec<Value>, Error>>,
) -> Result<bool, Error> {
Ok(true)
}
}