mirror of
				https://github.com/isar/rusqlite.git
				synced 2025-10-31 13:58:55 +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:
		| @@ -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, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user