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