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
impl Segment
Sourcepub const fn parse(value: &str) -> Result<&Self, ParseSegmentError>
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.
Sourcepub fn as_str(&self) -> &str
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);
Sourcepub const unsafe fn from_str_unchecked(s: &str) -> &Self
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
impl AsRef<Segment> for SegmentBuf
Source§impl Borrow<Segment> for SegmentBuf
impl Borrow<Segment> for SegmentBuf
Source§impl From<&Segment> for SegmentBuf
impl From<&Segment> for SegmentBuf
Source§impl PartialOrd for Segment
impl PartialOrd for Segment
Source§impl ToOwned for Segment
impl ToOwned for Segment
Source§type Owned = SegmentBuf
type Owned = SegmentBuf
The resulting type after obtaining ownership.
Source§fn to_owned(&self) -> Self::Owned
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)
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
impl ToSql for &Segment
Source§fn to_sql(
&self,
ty: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
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 moreSource§fn accepts(ty: &Type) -> boolwhere
Self: Sized,
fn accepts(ty: &Type) -> boolwhere
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>>
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