pub struct Variable { /* private fields */ }
Expand description
A SPARQL query owned variable.
The default string formatter is returning a SPARQL compatible representation:
use oxrdf::{Variable, VariableNameParseError};
assert_eq!(
"?foo",
Variable::new("foo")?.to_string()
);
Implementations§
source§impl Variable
impl Variable
sourcepub fn new(name: impl Into<String>) -> Result<Self, VariableNameParseError>
pub fn new(name: impl Into<String>) -> Result<Self, VariableNameParseError>
Creates a variable name from a unique identifier.
The variable identifier must be valid according to the SPARQL grammar.
sourcepub fn new_unchecked(name: impl Into<String>) -> Self
pub fn new_unchecked(name: impl Into<String>) -> Self
Creates a variable name from a unique identifier without validation.
It is the caller’s responsibility to ensure that id
is a valid blank node identifier
according to the SPARQL grammar.
Variable::new()
is a safe version of this constructor and should be used for untrusted data.
pub fn as_str(&self) -> &str
pub fn into_string(self) -> String
pub fn as_ref(&self) -> VariableRef<'_>
Trait Implementations§
source§impl<'a> From<&'a Variable> for VariableRef<'a>
impl<'a> From<&'a Variable> for VariableRef<'a>
source§impl<'a> From<VariableRef<'a>> for Variable
impl<'a> From<VariableRef<'a>> for Variable
source§fn from(variable: VariableRef<'a>) -> Self
fn from(variable: VariableRef<'a>) -> Self
Converts to this type from the input type.
source§impl FromStr for Variable
impl FromStr for Variable
source§fn from_str(s: &str) -> Result<Self, TermParseError>
fn from_str(s: &str) -> Result<Self, TermParseError>
Parses a variable from its SPARQL serialization
use oxrdf::Variable;
use std::str::FromStr;
assert_eq!(Variable::from_str("$foo").unwrap(), Variable::new("foo").unwrap())
§type Err = TermParseError
type Err = TermParseError
The associated error which can be returned from parsing.
source§impl Ord for Variable
impl Ord for Variable
source§impl PartialEq<Variable> for Variable
impl PartialEq<Variable> for Variable
source§impl PartialEq<Variable> for VariableRef<'_>
impl PartialEq<Variable> for VariableRef<'_>
source§impl PartialEq<VariableRef<'_>> for Variable
impl PartialEq<VariableRef<'_>> for Variable
source§fn eq(&self, other: &VariableRef<'_>) -> bool
fn eq(&self, other: &VariableRef<'_>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<Variable> for Variable
impl PartialOrd<Variable> for Variable
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<Variable> for VariableRef<'_>
impl PartialOrd<Variable> for VariableRef<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<VariableRef<'_>> for Variable
impl PartialOrd<VariableRef<'_>> for Variable
source§fn partial_cmp(&self, other: &VariableRef<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &VariableRef<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Variable
impl StructuralEq for Variable
impl StructuralPartialEq for Variable
Auto Trait Implementations§
impl RefUnwindSafe for Variable
impl Send for Variable
impl Sync for Variable
impl Unpin for Variable
impl UnwindSafe for Variable
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