Struct Constraint

Source
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

Source

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
Hide additional 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    }
Source

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
Hide additional 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    }
Source

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
Hide additional 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    }
Source

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
Hide additional 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    }
Source

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
Hide additional 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§

Source§

impl Debug for Constraint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.