pub struct Scope { /* private fields */ }
Expand description
Used to scope a Key
. Consists of a vector of zero or more
SegmentBuf
s.
Implementations§
Source§impl Scope
impl Scope
Sourcepub fn from_segment(segment: impl Into<SegmentBuf>) -> Scope
pub fn from_segment(segment: impl Into<SegmentBuf>) -> Scope
Sourcepub fn new(segments: Vec<SegmentBuf>) -> Scope
pub fn new(segments: Vec<SegmentBuf>) -> Scope
Create a Scope
from a vector of SegmentBuf
s.
§Example
use kvx_types::{Scope, Segment};
Scope::new(vec![Segment::parse("segment1")?.to_owned(), Segment::parse("segment2")?.to_owned()]);
Sourcepub fn as_vec(&self) -> &Vec<SegmentBuf>
pub fn as_vec(&self) -> &Vec<SegmentBuf>
Returns the underlying vector of SegmentBuf
s.
Sourcepub fn matches(&self, other: &Scope) -> bool
pub fn matches(&self, other: &Scope) -> bool
Two scopes match if the longest of the two contains all Segment
s
of the other.
Sourcepub fn starts_with(&self, prefix: &Scope) -> bool
pub fn starts_with(&self, prefix: &Scope) -> bool
Returns whether the encapsulated vector starts with a certain prefix.
Sourcepub fn sub_scopes(&self) -> Vec<Scope>
pub fn sub_scopes(&self) -> Vec<Scope>
Returns a vector of all prefixes of the scope.
Sourcepub fn with_sub_scope(&self, sub_scope: impl Into<SegmentBuf>) -> Scope
pub fn with_sub_scope(&self, sub_scope: impl Into<SegmentBuf>) -> Scope
Sourcepub fn add_sub_scope(&mut self, sub_scope: impl Into<SegmentBuf>)
pub fn add_sub_scope(&mut self, sub_scope: impl Into<SegmentBuf>)
Add a Segment
to the end of the scope.
Sourcepub fn with_super_scope(&self, super_scope: impl Into<SegmentBuf>) -> Scope
pub fn with_super_scope(&self, super_scope: impl Into<SegmentBuf>) -> Scope
Sourcepub fn add_super_scope(&mut self, super_scope: impl Into<SegmentBuf>)
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 Extend<SegmentBuf> for Scope
impl Extend<SegmentBuf> for Scope
Source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = SegmentBuf>,
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)
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)
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 FromIterator<SegmentBuf> for Scope
impl FromIterator<SegmentBuf> for Scope
Source§fn from_iter<T>(iter: T) -> Scopewhere
T: IntoIterator<Item = SegmentBuf>,
fn from_iter<T>(iter: T) -> Scopewhere
T: IntoIterator<Item = SegmentBuf>,
Creates a value from an iterator. Read more
Source§impl<'a> FromSql<'a> for Scope
impl<'a> FromSql<'a> for Scope
Source§fn from_sql(
_type: &Type,
buf: &'a [u8],
) -> Result<Scope, Box<dyn Error + Sync + Send>>
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 moreSource§fn accepts(type_: &Type) -> bool
fn accepts(type_: &Type) -> bool
Determines if a value of this type can be created from the specified
Postgres
Type
.Source§impl<'a> IntoIterator for &'a Scope
impl<'a> IntoIterator for &'a Scope
Source§type IntoIter = <&'a Vec<SegmentBuf> as IntoIterator>::IntoIter
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
type Item = <&'a Vec<SegmentBuf> as IntoIterator>::Item
The type of the elements being iterated over.
Source§impl IntoIterator for Scope
impl IntoIterator for Scope
Source§type IntoIter = <Vec<SegmentBuf> as IntoIterator>::IntoIter
type IntoIter = <Vec<SegmentBuf> as IntoIterator>::IntoIter
Which kind of iterator are we turning this into?
Source§type Item = <Vec<SegmentBuf> as IntoIterator>::Item
type Item = <Vec<SegmentBuf> as IntoIterator>::Item
The type of the elements being iterated over.
Source§impl Ord for Scope
impl Ord for Scope
Source§impl PartialOrd for Scope
impl PartialOrd for Scope
Source§impl ToSql for Scope
impl ToSql for Scope
Source§fn to_sql(
&self,
_type: &Type,
buf: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
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 moreSource§fn accepts(type_: &Type) -> bool
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>>
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
fn encode_format(&self, _ty: &Type) -> Format
Specify the encode format
impl Eq for Scope
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> 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
Source§impl<T> BorrowToSql for Twhere
T: ToSql,
impl<T> BorrowToSql for Twhere
T: ToSql,
Source§fn borrow_to_sql(&self) -> &dyn ToSql
fn borrow_to_sql(&self) -> &dyn ToSql
Returns a reference to
self
as a ToSql
trait object.