mirror of
				https://github.com/isar/rusqlite.git
				synced 2025-10-31 05:48:56 +08:00 
			
		
		
		
	Add #[non_exhaustive] to enums that might get new variants. (#673)
				
					
				
			This just using them in patterns without a catchall. I left things alone that seem very unlikely to change (`Value`, `ValueRef`, `DatabaseName`, etc...). This might help reduce the number of breaking changes we need (rusqlite is still pre-1.0 so it doesn't really matter that much, but breaking changes complicate the story around when we can cut releases).
This commit is contained in:
		| @@ -4,6 +4,7 @@ use std::os::raw::c_int; | |||||||
|  |  | ||||||
| /// Error Codes | /// Error Codes | ||||||
| #[derive(Clone, Copy, Debug, PartialEq, Eq)] | #[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||||||
|  | #[non_exhaustive] | ||||||
| pub enum ErrorCode { | pub enum ErrorCode { | ||||||
|     /// Internal logic error in SQLite |     /// Internal logic error in SQLite | ||||||
|     InternalMalfunction, |     InternalMalfunction, | ||||||
|   | |||||||
| @@ -17,6 +17,7 @@ pub fn SQLITE_TRANSIENT() -> sqlite3_destructor_type { | |||||||
|  |  | ||||||
| /// Run-Time Limit Categories | /// Run-Time Limit Categories | ||||||
| #[repr(i32)] | #[repr(i32)] | ||||||
|  | #[non_exhaustive] | ||||||
| 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, | ||||||
|   | |||||||
| @@ -132,6 +132,7 @@ impl Connection { | |||||||
|  |  | ||||||
| /// `feature = "backup"` Possible successful results of calling `Backup::step`. | /// `feature = "backup"` Possible successful results of calling `Backup::step`. | ||||||
| #[derive(Copy, Clone, Debug, PartialEq, Eq)] | #[derive(Copy, Clone, Debug, PartialEq, Eq)] | ||||||
|  | #[non_exhaustive] | ||||||
| pub enum StepResult { | pub enum StepResult { | ||||||
|     /// The backup is complete. |     /// The backup is complete. | ||||||
|     Done, |     Done, | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ use crate::{Connection, Result}; | |||||||
| /// Database Connection Configuration Options | /// Database Connection Configuration Options | ||||||
| #[repr(i32)] | #[repr(i32)] | ||||||
| #[allow(non_snake_case, non_camel_case_types)] | #[allow(non_snake_case, non_camel_case_types)] | ||||||
|  | #[non_exhaustive] | ||||||
| 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 */ | ||||||
|   | |||||||
| @@ -10,6 +10,7 @@ use std::str; | |||||||
| /// Enum listing possible errors from rusqlite. | /// Enum listing possible errors from rusqlite. | ||||||
| #[derive(Debug)] | #[derive(Debug)] | ||||||
| #[allow(clippy::enum_variant_names)] | #[allow(clippy::enum_variant_names)] | ||||||
|  | #[non_exhaustive] | ||||||
| pub enum Error { | pub enum Error { | ||||||
|     /// An error from an underlying SQLite call. |     /// An error from an underlying SQLite call. | ||||||
|     SqliteFailure(ffi::Error, Option<String>), |     SqliteFailure(ffi::Error, Option<String>), | ||||||
|   | |||||||
| @@ -12,6 +12,7 @@ use crate::{Connection, InnerConnection}; | |||||||
| /// `feature = "hooks"` Action Codes | /// `feature = "hooks"` Action Codes | ||||||
| #[derive(Clone, Copy, Debug, PartialEq)] | #[derive(Clone, Copy, Debug, PartialEq)] | ||||||
| #[repr(i32)] | #[repr(i32)] | ||||||
|  | #[non_exhaustive] | ||||||
| pub enum Action { | pub enum Action { | ||||||
|     UNKNOWN = -1, |     UNKNOWN = -1, | ||||||
|     SQLITE_DELETE = ffi::SQLITE_DELETE, |     SQLITE_DELETE = ffi::SQLITE_DELETE, | ||||||
|   | |||||||
| @@ -638,6 +638,7 @@ impl Connection { | |||||||
| /// `feature = "session"` Constants passed to the conflict handler | /// `feature = "session"` Constants passed to the conflict handler | ||||||
| #[repr(i32)] | #[repr(i32)] | ||||||
| #[derive(Debug, PartialEq)] | #[derive(Debug, PartialEq)] | ||||||
|  | #[non_exhaustive] | ||||||
| pub enum ConflictType { | pub enum ConflictType { | ||||||
|     UNKNOWN = -1, |     UNKNOWN = -1, | ||||||
|     SQLITE_CHANGESET_DATA = ffi::SQLITE_CHANGESET_DATA, |     SQLITE_CHANGESET_DATA = ffi::SQLITE_CHANGESET_DATA, | ||||||
| @@ -662,6 +663,7 @@ impl From<i32> for ConflictType { | |||||||
| /// `feature = "session"` Constants returned by the conflict handler | /// `feature = "session"` Constants returned by the conflict handler | ||||||
| #[repr(i32)] | #[repr(i32)] | ||||||
| #[derive(Debug, PartialEq)] | #[derive(Debug, PartialEq)] | ||||||
|  | #[non_exhaustive] | ||||||
| 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, | ||||||
|   | |||||||
| @@ -822,6 +822,7 @@ impl Statement<'_> { | |||||||
| /// may not be available. | /// may not be available. | ||||||
| #[repr(i32)] | #[repr(i32)] | ||||||
| #[derive(Clone, Copy, PartialEq, Eq)] | #[derive(Clone, Copy, PartialEq, Eq)] | ||||||
|  | #[non_exhaustive] | ||||||
| pub enum StatementStatus { | pub enum StatementStatus { | ||||||
|     /// Equivalent to SQLITE_STMTSTATUS_FULLSCAN_STEP |     /// Equivalent to SQLITE_STMTSTATUS_FULLSCAN_STEP | ||||||
|     FullscanStep = 1, |     FullscanStep = 1, | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ use std::ops::Deref; | |||||||
| /// Options for transaction behavior. See [BEGIN | /// Options for transaction behavior. See [BEGIN | ||||||
| /// TRANSACTION](http://www.sqlite.org/lang_transaction.html) for details. | /// TRANSACTION](http://www.sqlite.org/lang_transaction.html) for details. | ||||||
| #[derive(Copy, Clone)] | #[derive(Copy, Clone)] | ||||||
|  | #[non_exhaustive] | ||||||
| pub enum TransactionBehavior { | pub enum TransactionBehavior { | ||||||
|     Deferred, |     Deferred, | ||||||
|     Immediate, |     Immediate, | ||||||
| @@ -12,6 +13,7 @@ pub enum TransactionBehavior { | |||||||
|  |  | ||||||
| /// Options for how a Transaction or Savepoint should behave when it is dropped. | /// Options for how a Transaction or Savepoint should behave when it is dropped. | ||||||
| #[derive(Copy, Clone, Debug, PartialEq, Eq)] | #[derive(Copy, Clone, Debug, PartialEq, Eq)] | ||||||
|  | #[non_exhaustive] | ||||||
| pub enum DropBehavior { | pub enum DropBehavior { | ||||||
|     /// Roll back the changes. This is the default. |     /// Roll back the changes. This is the default. | ||||||
|     Rollback, |     Rollback, | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ use std::fmt; | |||||||
|  |  | ||||||
| /// Enum listing possible errors from `FromSql` trait. | /// Enum listing possible errors from `FromSql` trait. | ||||||
| #[derive(Debug)] | #[derive(Debug)] | ||||||
|  | #[non_exhaustive] | ||||||
| pub enum FromSqlError { | pub enum FromSqlError { | ||||||
|     /// Error when an SQLite value is requested, but the type of the result |     /// Error when an SQLite value is requested, but the type of the result | ||||||
|     /// cannot be converted to the requested Rust type. |     /// cannot be converted to the requested Rust type. | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ use std::borrow::Cow; | |||||||
| /// `ToSqlOutput` represents the possible output types for implementors of the | /// `ToSqlOutput` represents the possible output types for implementors of the | ||||||
| /// `ToSql` trait. | /// `ToSql` trait. | ||||||
| #[derive(Clone, Debug, PartialEq)] | #[derive(Clone, Debug, PartialEq)] | ||||||
|  | #[non_exhaustive] | ||||||
| pub enum ToSqlOutput<'a> { | pub enum ToSqlOutput<'a> { | ||||||
|     /// A borrowed SQLite-representable value. |     /// A borrowed SQLite-representable value. | ||||||
|     Borrowed(ValueRef<'a>), |     Borrowed(ValueRef<'a>), | ||||||
|   | |||||||
| @@ -247,6 +247,7 @@ pub trait CreateVTab: VTab { | |||||||
| /// `feature = "vtab"` Index constraint operator. | /// `feature = "vtab"` Index constraint operator. | ||||||
| #[derive(Debug, PartialEq)] | #[derive(Debug, PartialEq)] | ||||||
| #[allow(non_snake_case, non_camel_case_types)] | #[allow(non_snake_case, non_camel_case_types)] | ||||||
|  | #[non_exhaustive] | ||||||
| pub enum IndexConstraintOp { | pub enum IndexConstraintOp { | ||||||
|     SQLITE_INDEX_CONSTRAINT_EQ, |     SQLITE_INDEX_CONSTRAINT_EQ, | ||||||
|     SQLITE_INDEX_CONSTRAINT_GT, |     SQLITE_INDEX_CONSTRAINT_GT, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user