Struct Segment

Source
pub struct Segment(/* private fields */);
Expand description

A nonempty string slice that does not start or end with whitespace and does not contain any instances of Scope::SEPARATOR.

For the owned variant, see SegmentBuf.

Implementations§

Source§

impl Segment

Source

pub const fn parse(value: &str) -> Result<&Self, ParseSegmentError>

Parse a Segment from a string.

§Examples
use kvx_types::Segment;

Segment::parse("segment")?;
§Errors

If the string is empty, starts or ends with whitespace, or contains a Scope::SEPARATOR a ParseSegmentError variant will be returned.

Source

pub fn as_str(&self) -> &str

Return the encapsulated string.

§Examples
use kvx_types::Segment;

let segment_str = "segment";
let segment = Segment::parse(segment_str)?;
assert_eq!(segment.as_str(), segment_str);
Source

pub const unsafe fn from_str_unchecked(s: &str) -> &Self

Creates a Segment from a string without performing any checks.

§Safety

This function should only be called from the kvx_macros crate - do not use directly.

Trait Implementations§

Source§

impl AsRef<Segment> for SegmentBuf

Source§

fn as_ref(&self) -> &Segment

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<Segment> for SegmentBuf

Source§

fn borrow(&self) -> &Segment

Immutably borrows from an owned value. Read more
Source§

impl Debug for Segment

Source§

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

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

impl Display for Segment

Source§

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

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

impl From<&Segment> for SegmentBuf

Source§

fn from(value: &Segment) -> Self

Converts to this type from the input type.
Source§

impl Hash for Segment

Source§

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

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

impl Ord for Segment

Source§

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

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

impl PartialEq for Segment

Source§

fn eq(&self, other: &Segment) -> 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 Segment

Source§

fn partial_cmp(&self, other: &Segment) -> 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 ToOwned for Segment

Source§

type Owned = SegmentBuf

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> Self::Owned

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

fn clone_into(&self, target: &mut Self::Owned)

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

impl ToSql for &Segment

Source§

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

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

fn accepts(ty: &Type) -> bool
where Self: Sized,

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 Segment

Source§

impl StructuralPartialEq for Segment

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more