pub struct Constraint {
pub constraint: sqlite3_index_info_sqlite3_index_constraint,
pub usage: *mut sqlite3_index_info_sqlite3_index_constraint_usage,
}
Expand description
Wraps the raw sqlite3_index_constraint and sqlite3_index_constraint_usage C structs for ergonomic use in Rust.
Fields§
§constraint: sqlite3_index_info_sqlite3_index_constraint
§usage: *mut sqlite3_index_info_sqlite3_index_constraint_usage
Implementations§
Source§impl Constraint
impl Constraint
Sourcepub fn column_idx(&self) -> i32
pub fn column_idx(&self) -> i32
Examples found in repository?
examples/characters.rs (line 52)
49 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
50 let mut has_input = false;
51 for mut constraint in info.constraints() {
52 match column(constraint.column_idx()) {
53 Some(Columns::Input) => {
54 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
55 constraint.set_omit(true);
56 constraint.set_argv_index(1);
57 has_input = true;
58 } else {
59 return Err(BestIndexError::Constraint);
60 }
61 }
62 _ => todo!(),
63 }
64 }
65 if !has_input {
66 return Err(BestIndexError::Error);
67 }
68 info.set_estimated_cost(100000.0);
69 info.set_estimated_rows(100000);
70 info.set_idxnum(1);
71
72 Ok(())
73 }
More examples
examples/series.rs (line 58)
54 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
55 let mut has_start = false;
56 let mut has_stop = false;
57 for mut constraint in info.constraints() {
58 match column(constraint.column_idx()) {
59 Some(Columns::Start) => {
60 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
61 constraint.set_omit(true);
62 constraint.set_argv_index(1);
63 has_start = true;
64 } else {
65 return Err(BestIndexError::Constraint);
66 }
67 }
68 Some(Columns::Stop) => {
69 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
70 constraint.set_omit(true);
71 constraint.set_argv_index(2);
72 has_stop = true;
73 } else {
74 return Err(BestIndexError::Constraint);
75 }
76 }
77 _ => todo!(),
78 }
79 }
80 if !has_start || !has_stop {
81 return Err(BestIndexError::Error);
82 }
83 info.set_estimated_cost(100000.0);
84 info.set_estimated_rows(100000);
85 info.set_idxnum(1);
86
87 Ok(())
88 }
Sourcepub fn usable(&self) -> bool
pub fn usable(&self) -> bool
Examples found in repository?
examples/characters.rs (line 54)
49 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
50 let mut has_input = false;
51 for mut constraint in info.constraints() {
52 match column(constraint.column_idx()) {
53 Some(Columns::Input) => {
54 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
55 constraint.set_omit(true);
56 constraint.set_argv_index(1);
57 has_input = true;
58 } else {
59 return Err(BestIndexError::Constraint);
60 }
61 }
62 _ => todo!(),
63 }
64 }
65 if !has_input {
66 return Err(BestIndexError::Error);
67 }
68 info.set_estimated_cost(100000.0);
69 info.set_estimated_rows(100000);
70 info.set_idxnum(1);
71
72 Ok(())
73 }
More examples
examples/series.rs (line 60)
54 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
55 let mut has_start = false;
56 let mut has_stop = false;
57 for mut constraint in info.constraints() {
58 match column(constraint.column_idx()) {
59 Some(Columns::Start) => {
60 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
61 constraint.set_omit(true);
62 constraint.set_argv_index(1);
63 has_start = true;
64 } else {
65 return Err(BestIndexError::Constraint);
66 }
67 }
68 Some(Columns::Stop) => {
69 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
70 constraint.set_omit(true);
71 constraint.set_argv_index(2);
72 has_stop = true;
73 } else {
74 return Err(BestIndexError::Constraint);
75 }
76 }
77 _ => todo!(),
78 }
79 }
80 if !has_start || !has_stop {
81 return Err(BestIndexError::Error);
82 }
83 info.set_estimated_cost(100000.0);
84 info.set_estimated_rows(100000);
85 info.set_idxnum(1);
86
87 Ok(())
88 }
Sourcepub fn op(&self) -> Option<ConstraintOperator>
pub fn op(&self) -> Option<ConstraintOperator>
Examples found in repository?
examples/characters.rs (line 54)
49 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
50 let mut has_input = false;
51 for mut constraint in info.constraints() {
52 match column(constraint.column_idx()) {
53 Some(Columns::Input) => {
54 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
55 constraint.set_omit(true);
56 constraint.set_argv_index(1);
57 has_input = true;
58 } else {
59 return Err(BestIndexError::Constraint);
60 }
61 }
62 _ => todo!(),
63 }
64 }
65 if !has_input {
66 return Err(BestIndexError::Error);
67 }
68 info.set_estimated_cost(100000.0);
69 info.set_estimated_rows(100000);
70 info.set_idxnum(1);
71
72 Ok(())
73 }
More examples
examples/series.rs (line 60)
54 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
55 let mut has_start = false;
56 let mut has_stop = false;
57 for mut constraint in info.constraints() {
58 match column(constraint.column_idx()) {
59 Some(Columns::Start) => {
60 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
61 constraint.set_omit(true);
62 constraint.set_argv_index(1);
63 has_start = true;
64 } else {
65 return Err(BestIndexError::Constraint);
66 }
67 }
68 Some(Columns::Stop) => {
69 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
70 constraint.set_omit(true);
71 constraint.set_argv_index(2);
72 has_stop = true;
73 } else {
74 return Err(BestIndexError::Constraint);
75 }
76 }
77 _ => todo!(),
78 }
79 }
80 if !has_start || !has_stop {
81 return Err(BestIndexError::Error);
82 }
83 info.set_estimated_cost(100000.0);
84 info.set_estimated_rows(100000);
85 info.set_idxnum(1);
86
87 Ok(())
88 }
Sourcepub fn set_argv_index(&mut self, i: i32)
pub fn set_argv_index(&mut self, i: i32)
Examples found in repository?
examples/characters.rs (line 56)
49 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
50 let mut has_input = false;
51 for mut constraint in info.constraints() {
52 match column(constraint.column_idx()) {
53 Some(Columns::Input) => {
54 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
55 constraint.set_omit(true);
56 constraint.set_argv_index(1);
57 has_input = true;
58 } else {
59 return Err(BestIndexError::Constraint);
60 }
61 }
62 _ => todo!(),
63 }
64 }
65 if !has_input {
66 return Err(BestIndexError::Error);
67 }
68 info.set_estimated_cost(100000.0);
69 info.set_estimated_rows(100000);
70 info.set_idxnum(1);
71
72 Ok(())
73 }
More examples
examples/series.rs (line 62)
54 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
55 let mut has_start = false;
56 let mut has_stop = false;
57 for mut constraint in info.constraints() {
58 match column(constraint.column_idx()) {
59 Some(Columns::Start) => {
60 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
61 constraint.set_omit(true);
62 constraint.set_argv_index(1);
63 has_start = true;
64 } else {
65 return Err(BestIndexError::Constraint);
66 }
67 }
68 Some(Columns::Stop) => {
69 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
70 constraint.set_omit(true);
71 constraint.set_argv_index(2);
72 has_stop = true;
73 } else {
74 return Err(BestIndexError::Constraint);
75 }
76 }
77 _ => todo!(),
78 }
79 }
80 if !has_start || !has_stop {
81 return Err(BestIndexError::Error);
82 }
83 info.set_estimated_cost(100000.0);
84 info.set_estimated_rows(100000);
85 info.set_idxnum(1);
86
87 Ok(())
88 }
Sourcepub fn set_omit(&mut self, value: bool)
pub fn set_omit(&mut self, value: bool)
Examples found in repository?
examples/characters.rs (line 55)
49 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
50 let mut has_input = false;
51 for mut constraint in info.constraints() {
52 match column(constraint.column_idx()) {
53 Some(Columns::Input) => {
54 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
55 constraint.set_omit(true);
56 constraint.set_argv_index(1);
57 has_input = true;
58 } else {
59 return Err(BestIndexError::Constraint);
60 }
61 }
62 _ => todo!(),
63 }
64 }
65 if !has_input {
66 return Err(BestIndexError::Error);
67 }
68 info.set_estimated_cost(100000.0);
69 info.set_estimated_rows(100000);
70 info.set_idxnum(1);
71
72 Ok(())
73 }
More examples
examples/series.rs (line 61)
54 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
55 let mut has_start = false;
56 let mut has_stop = false;
57 for mut constraint in info.constraints() {
58 match column(constraint.column_idx()) {
59 Some(Columns::Start) => {
60 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
61 constraint.set_omit(true);
62 constraint.set_argv_index(1);
63 has_start = true;
64 } else {
65 return Err(BestIndexError::Constraint);
66 }
67 }
68 Some(Columns::Stop) => {
69 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
70 constraint.set_omit(true);
71 constraint.set_argv_index(2);
72 has_stop = true;
73 } else {
74 return Err(BestIndexError::Constraint);
75 }
76 }
77 _ => todo!(),
78 }
79 }
80 if !has_start || !has_stop {
81 return Err(BestIndexError::Error);
82 }
83 info.set_estimated_cost(100000.0);
84 info.set_estimated_rows(100000);
85 info.set_idxnum(1);
86
87 Ok(())
88 }
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Constraint
impl RefUnwindSafe for Constraint
impl !Send for Constraint
impl !Sync for Constraint
impl Unpin for Constraint
impl UnwindSafe for Constraint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more