Struct Scope

Source
pub struct Scope { /* private fields */ }
Expand description

Used to scope a Key. Consists of a vector of zero or more SegmentBufs.

Implementations§

Source§

impl Scope

Source

pub const SEPARATOR: char = '/'

Character used to split on when parsing a Scope from a string.

Source

pub fn from_segment(segment: impl Into<SegmentBuf>) -> Scope

Create a Scope from a single Segment.

§Example
use kvx_types::{Scope, Segment};

Scope::from_segment(Segment::parse("segment")?);
Source

pub fn global() -> Scope

Create an empty Scope.

§Example
use kvx_types::Scope;

Scope::global();
Source

pub fn new(segments: Vec<SegmentBuf>) -> Scope

Create a Scope from a vector of SegmentBufs.

§Example
use kvx_types::{Scope, Segment};

Scope::new(vec![Segment::parse("segment1")?.to_owned(), Segment::parse("segment2")?.to_owned()]);
Source

pub fn as_vec(&self) -> &Vec<SegmentBuf>

Returns the underlying vector of SegmentBufs.

Source

pub fn len(&self) -> i32

Returns the length of the underlying vector.

Source

pub fn is_global(&self) -> bool

Returns whether the underlying vector is empty.

Source

pub fn matches(&self, other: &Scope) -> bool

Two scopes match if the longest of the two contains all Segments of the other.

Source

pub fn starts_with(&self, prefix: &Scope) -> bool

Returns whether the encapsulated vector starts with a certain prefix.

Source

pub fn sub_scopes(&self) -> Vec<Scope>

Returns a vector of all prefixes of the scope.

Source

pub fn with_sub_scope(&self, sub_scope: impl Into<SegmentBuf>) -> Scope

Create a new Scope and add a Segment to the end of it.

Source

pub fn add_sub_scope(&mut self, sub_scope: impl Into<SegmentBuf>)

Add a Segment to the end of the scope.

Source

pub fn with_super_scope(&self, super_scope: impl Into<SegmentBuf>) -> Scope

Create a new Scope and add a Segment to the front of it.

Source

pub fn add_super_scope(&mut self, super_scope: impl Into<SegmentBuf>)

Add a Segment to the front of the scope.

Trait Implementations§

Source§

impl Clone for Scope

Source§

fn clone(&self) -> Scope

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Scope

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Scope

Source§

fn default() -> Scope

Returns the “default value” for a type. Read more
Source§

impl Display for Scope

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Extend<SegmentBuf> for Scope

Source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = SegmentBuf>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<Vec<SegmentBuf>> for Scope

Source§

fn from(segments: Vec<SegmentBuf>) -> Scope

Converts to this type from the input type.
Source§

impl FromIterator<SegmentBuf> for Scope

Source§

fn from_iter<T>(iter: T) -> Scope
where T: IntoIterator<Item = SegmentBuf>,

Creates a value from an iterator. Read more
Source§

impl<'a> FromSql<'a> for Scope

Source§

fn from_sql( _type: &Type, buf: &'a [u8], ) -> Result<Scope, Box<dyn Error + Sync + Send>>

Creates a new value of this type from a buffer of data of the specified Postgres Type in its binary format. Read more
Source§

fn accepts(type_: &Type) -> bool

Determines if a value of this type can be created from the specified Postgres Type.
Source§

fn from_sql_null(ty: &Type) -> Result<Self, Box<dyn Error + Sync + Send>>

Creates a new value of this type from a NULL SQL value. Read more
Source§

fn from_sql_nullable( ty: &Type, raw: Option<&'a [u8]>, ) -> Result<Self, Box<dyn Error + Sync + Send>>

A convenience function that delegates to from_sql and from_sql_null depending on the value of raw.
Source§

impl FromStr for Scope

Source§

type Err = ParseSegmentError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Scope, <Scope as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Scope

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> IntoIterator for &'a Scope

Source§

type IntoIter = <&'a Vec<SegmentBuf> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

type Item = <&'a Vec<SegmentBuf> as IntoIterator>::Item

The type of the elements being iterated over.
Source§

fn into_iter(self) -> <&'a Scope as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for Scope

Source§

type IntoIter = <Vec<SegmentBuf> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

type Item = <Vec<SegmentBuf> as IntoIterator>::Item

The type of the elements being iterated over.
Source§

fn into_iter(self) -> <Scope as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl Ord for Scope

Source§

fn cmp(&self, other: &Scope) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Scope

Source§

fn eq(&self, other: &Scope) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Scope

Source§

fn partial_cmp(&self, other: &Scope) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl ToSql for Scope

Source§

fn to_sql( &self, _type: &Type, buf: &mut BytesMut, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

Converts the value of self into the binary format of the specified Postgres Type, appending it to out. Read more
Source§

fn accepts(type_: &Type) -> bool

Determines if a value of this type can be converted to the specified Postgres Type.
Source§

fn to_sql_checked( &self, ty: &Type, out: &mut BytesMut, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

An adaptor method used internally by Rust-Postgres. Read more
Source§

fn encode_format(&self, _ty: &Type) -> Format

Specify the encode format
Source§

impl Eq for Scope

Source§

impl StructuralPartialEq for Scope

Auto Trait Implementations§

§

impl Freeze for Scope

§

impl RefUnwindSafe for Scope

§

impl Send for Scope

§

impl Sync for Scope

§

impl Unpin for Scope

§

impl UnwindSafe for Scope

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> BorrowToSql for T
where T: ToSql,

Source§

fn borrow_to_sql(&self) -> &dyn ToSql

Returns a reference to self as a ToSql trait object.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> FromSqlOwned for T
where T: for<'a> FromSql<'a>,

Source§

impl<T> MaybeSendSync for T