mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Silent some clippy warnings (#924)
* allow(clippy::upper_case_acronyms) for rust enum entries that match SQLite constants. * allow(clippy::needless_return) for collation_needed_callback until we find a way to propagate the error.
This commit is contained in:
parent
df3252dfb8
commit
ed3bfbdf9d
@ -23,7 +23,7 @@ pub enum ErrorCode {
|
||||
/// Operation terminated by sqlite3_interrupt()
|
||||
OperationInterrupted,
|
||||
/// Some kind of disk I/O error occurred
|
||||
SystemIOFailure,
|
||||
SystemIoFailure,
|
||||
/// The database disk image is malformed
|
||||
DatabaseCorrupt,
|
||||
/// Unknown opcode in sqlite3_file_control()
|
||||
@ -43,7 +43,7 @@ pub enum ErrorCode {
|
||||
/// Data type mismatch
|
||||
TypeMismatch,
|
||||
/// Library used incorrectly
|
||||
APIMisuse,
|
||||
ApiMisuse,
|
||||
/// Uses OS features not supported on host
|
||||
NoLargeFileSupport,
|
||||
/// Authorization denied
|
||||
@ -73,7 +73,7 @@ impl Error {
|
||||
super::SQLITE_NOMEM => ErrorCode::OutOfMemory,
|
||||
super::SQLITE_READONLY => ErrorCode::ReadOnly,
|
||||
super::SQLITE_INTERRUPT => ErrorCode::OperationInterrupted,
|
||||
super::SQLITE_IOERR => ErrorCode::SystemIOFailure,
|
||||
super::SQLITE_IOERR => ErrorCode::SystemIoFailure,
|
||||
super::SQLITE_CORRUPT => ErrorCode::DatabaseCorrupt,
|
||||
super::SQLITE_NOTFOUND => ErrorCode::NotFound,
|
||||
super::SQLITE_FULL => ErrorCode::DiskFull,
|
||||
@ -83,7 +83,7 @@ impl Error {
|
||||
super::SQLITE_TOOBIG => ErrorCode::TooBig,
|
||||
super::SQLITE_CONSTRAINT => ErrorCode::ConstraintViolation,
|
||||
super::SQLITE_MISMATCH => ErrorCode::TypeMismatch,
|
||||
super::SQLITE_MISUSE => ErrorCode::APIMisuse,
|
||||
super::SQLITE_MISUSE => ErrorCode::ApiMisuse,
|
||||
super::SQLITE_NOLFS => ErrorCode::NoLargeFileSupport,
|
||||
super::SQLITE_AUTH => ErrorCode::AuthorizationForStatementDenied,
|
||||
super::SQLITE_RANGE => ErrorCode::ParameterOutOfRange,
|
||||
|
@ -18,6 +18,7 @@ pub fn SQLITE_TRANSIENT() -> sqlite3_destructor_type {
|
||||
/// Run-Time Limit Categories
|
||||
#[repr(i32)]
|
||||
#[non_exhaustive]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub enum Limit {
|
||||
/// The maximum size of any string or BLOB or table row, in bytes.
|
||||
SQLITE_LIMIT_LENGTH = SQLITE_LIMIT_LENGTH,
|
||||
|
@ -109,6 +109,7 @@ impl InnerConnection {
|
||||
x_coll_needed: fn(&Connection, &str) -> Result<()>,
|
||||
) -> Result<()> {
|
||||
use std::mem;
|
||||
#[allow(clippy::needless_return)]
|
||||
unsafe extern "C" fn collation_needed_callback(
|
||||
arg1: *mut c_void,
|
||||
arg2: *mut ffi::sqlite3,
|
||||
|
@ -10,6 +10,7 @@ use crate::{Connection, Result};
|
||||
#[repr(i32)]
|
||||
#[allow(non_snake_case, non_camel_case_types)]
|
||||
#[non_exhaustive]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub enum DbConfig {
|
||||
//SQLITE_DBCONFIG_MAINDBNAME = 1000, /* const char* */
|
||||
//SQLITE_DBCONFIG_LOOKASIDE = 1001, /* void* int int */
|
||||
|
@ -13,6 +13,7 @@ use crate::{Connection, InnerConnection};
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[repr(i32)]
|
||||
#[non_exhaustive]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub enum Action {
|
||||
/// Unsupported / unexpected action
|
||||
UNKNOWN = -1,
|
||||
|
@ -667,6 +667,7 @@ impl Connection {
|
||||
#[repr(i32)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub enum ConflictType {
|
||||
UNKNOWN = -1,
|
||||
SQLITE_CHANGESET_DATA = ffi::SQLITE_CHANGESET_DATA,
|
||||
@ -694,6 +695,7 @@ impl From<i32> for ConflictType {
|
||||
#[repr(i32)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub enum ConflictAction {
|
||||
SQLITE_CHANGESET_OMIT = ffi::SQLITE_CHANGESET_OMIT,
|
||||
SQLITE_CHANGESET_REPLACE = ffi::SQLITE_CHANGESET_REPLACE,
|
||||
|
@ -48,12 +48,12 @@ use crate::{Connection, Error, Result};
|
||||
/// ```
|
||||
pub fn load_module(conn: &Connection) -> Result<()> {
|
||||
let aux: Option<()> = None;
|
||||
conn.create_module("csv", read_only_module::<CSVTab>(), aux)
|
||||
conn.create_module("csv", read_only_module::<CsvTab>(), aux)
|
||||
}
|
||||
|
||||
/// An instance of the CSV virtual table
|
||||
#[repr(C)]
|
||||
struct CSVTab {
|
||||
struct CsvTab {
|
||||
/// Base class. Must be first
|
||||
base: ffi::sqlite3_vtab,
|
||||
/// Name of the CSV file
|
||||
@ -65,7 +65,7 @@ struct CSVTab {
|
||||
offset_first_row: csv::Position,
|
||||
}
|
||||
|
||||
impl CSVTab {
|
||||
impl CsvTab {
|
||||
fn reader(&self) -> Result<csv::Reader<File>, csv::Error> {
|
||||
csv::ReaderBuilder::new()
|
||||
.has_headers(self.has_headers)
|
||||
@ -96,20 +96,20 @@ impl CSVTab {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'vtab> VTab<'vtab> for CSVTab {
|
||||
unsafe impl<'vtab> VTab<'vtab> for CsvTab {
|
||||
type Aux = ();
|
||||
type Cursor = CSVTabCursor<'vtab>;
|
||||
type Cursor = CsvTabCursor<'vtab>;
|
||||
|
||||
fn connect(
|
||||
_: &mut VTabConnection,
|
||||
_aux: Option<&()>,
|
||||
args: &[&[u8]],
|
||||
) -> Result<(String, CSVTab)> {
|
||||
) -> Result<(String, CsvTab)> {
|
||||
if args.len() < 4 {
|
||||
return Err(Error::ModuleError("no CSV file specified".to_owned()));
|
||||
}
|
||||
|
||||
let mut vtab = CSVTab {
|
||||
let mut vtab = CsvTab {
|
||||
base: ffi::sqlite3_vtab::default(),
|
||||
filename: "".to_owned(),
|
||||
has_headers: false,
|
||||
@ -122,7 +122,7 @@ unsafe impl<'vtab> VTab<'vtab> for CSVTab {
|
||||
|
||||
let args = &args[3..];
|
||||
for c_slice in args {
|
||||
let (param, value) = CSVTab::parameter(c_slice)?;
|
||||
let (param, value) = CsvTab::parameter(c_slice)?;
|
||||
match param {
|
||||
"filename" => {
|
||||
if !Path::new(value).exists() {
|
||||
@ -166,7 +166,7 @@ unsafe impl<'vtab> VTab<'vtab> for CSVTab {
|
||||
}
|
||||
}
|
||||
"delimiter" => {
|
||||
if let Some(b) = CSVTab::parse_byte(value) {
|
||||
if let Some(b) = CsvTab::parse_byte(value) {
|
||||
vtab.delimiter = b;
|
||||
} else {
|
||||
return Err(Error::ModuleError(format!(
|
||||
@ -176,7 +176,7 @@ unsafe impl<'vtab> VTab<'vtab> for CSVTab {
|
||||
}
|
||||
}
|
||||
"quote" => {
|
||||
if let Some(b) = CSVTab::parse_byte(value) {
|
||||
if let Some(b) = CsvTab::parse_byte(value) {
|
||||
if b == b'0' {
|
||||
vtab.quote = 0;
|
||||
} else {
|
||||
@ -259,16 +259,16 @@ unsafe impl<'vtab> VTab<'vtab> for CSVTab {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn open(&self) -> Result<CSVTabCursor<'_>> {
|
||||
Ok(CSVTabCursor::new(self.reader()?))
|
||||
fn open(&self) -> Result<CsvTabCursor<'_>> {
|
||||
Ok(CsvTabCursor::new(self.reader()?))
|
||||
}
|
||||
}
|
||||
|
||||
impl CreateVTab<'_> for CSVTab {}
|
||||
impl CreateVTab<'_> for CsvTab {}
|
||||
|
||||
/// A cursor for the CSV virtual table
|
||||
#[repr(C)]
|
||||
struct CSVTabCursor<'vtab> {
|
||||
struct CsvTabCursor<'vtab> {
|
||||
/// Base class. Must be first
|
||||
base: ffi::sqlite3_vtab_cursor,
|
||||
/// The CSV reader object
|
||||
@ -278,12 +278,12 @@ struct CSVTabCursor<'vtab> {
|
||||
/// Values of the current row
|
||||
cols: csv::StringRecord,
|
||||
eof: bool,
|
||||
phantom: PhantomData<&'vtab CSVTab>,
|
||||
phantom: PhantomData<&'vtab CsvTab>,
|
||||
}
|
||||
|
||||
impl CSVTabCursor<'_> {
|
||||
fn new<'vtab>(reader: csv::Reader<File>) -> CSVTabCursor<'vtab> {
|
||||
CSVTabCursor {
|
||||
impl CsvTabCursor<'_> {
|
||||
fn new<'vtab>(reader: csv::Reader<File>) -> CsvTabCursor<'vtab> {
|
||||
CsvTabCursor {
|
||||
base: ffi::sqlite3_vtab_cursor::default(),
|
||||
reader,
|
||||
row_number: 0,
|
||||
@ -294,12 +294,12 @@ impl CSVTabCursor<'_> {
|
||||
}
|
||||
|
||||
/// Accessor to the associated virtual table.
|
||||
fn vtab(&self) -> &CSVTab {
|
||||
unsafe { &*(self.base.pVtab as *const CSVTab) }
|
||||
fn vtab(&self) -> &CsvTab {
|
||||
unsafe { &*(self.base.pVtab as *const CsvTab) }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl VTabCursor for CSVTabCursor<'_> {
|
||||
unsafe impl VTabCursor for CsvTabCursor<'_> {
|
||||
// Only a full table scan is supported. So `filter` simply rewinds to
|
||||
// the beginning.
|
||||
fn filter(
|
||||
|
@ -261,6 +261,7 @@ pub trait CreateVTab<'vtab>: VTab<'vtab> {
|
||||
/// See [Virtual Table Constraint Operator Codes](https://sqlite.org/c3ref/c_index_constraint_eq.html) for details.
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[allow(non_snake_case, non_camel_case_types, missing_docs)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub enum IndexConstraintOp {
|
||||
SQLITE_INDEX_CONSTRAINT_EQ,
|
||||
SQLITE_INDEX_CONSTRAINT_GT,
|
||||
|
Loading…
Reference in New Issue
Block a user