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<Variable, VariableNameParseError>
pub fn new(name: impl Into<String>) -> Result<Variable, 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>) -> Variable
pub fn new_unchecked(name: impl Into<String>) -> Variable
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§fn from(variable: &'a Variable) -> VariableRef<'a>
fn from(variable: &'a Variable) -> VariableRef<'a>
Converts to this type from the input type.
Source§impl<'a> From<VariableRef<'a>> for Variable
impl<'a> From<VariableRef<'a>> for Variable
Source§fn from(variable: VariableRef<'a>) -> Variable
fn from(variable: VariableRef<'a>) -> Variable
Converts to this type from the input type.
Source§impl FromStr for Variable
impl FromStr for Variable
Source§fn from_str(s: &str) -> Result<Variable, <Variable as FromStr>::Err>
fn from_str(s: &str) -> Result<Variable, <Variable as FromStr>::Err>
Parses a variable from its SPARQL serialization
use oxrdf::Variable;
use std::str::FromStr;
assert_eq!(Variable::from_str("$foo")?, Variable::new("foo")?);
Source§type Err = TermParseError
type Err = TermParseError
The associated error which can be returned from parsing.
Source§impl Index<&Variable> for QuerySolution
impl Index<&Variable> for QuerySolution
Source§impl Index<Variable> for QuerySolution
impl Index<Variable> for QuerySolution
Source§impl Ord for Variable
impl Ord 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§impl PartialOrd<Variable> for VariableRef<'_>
impl PartialOrd<Variable> for VariableRef<'_>
Source§impl PartialOrd<VariableRef<'_>> for Variable
impl PartialOrd<VariableRef<'_>> for Variable
Source§impl PartialOrd for Variable
impl PartialOrd for Variable
Source§impl VariableSolutionIndex for &Variable
impl VariableSolutionIndex for &Variable
Source§impl VariableSolutionIndex for Variable
impl VariableSolutionIndex for Variable
impl Eq for Variable
impl StructuralPartialEq for Variable
Auto Trait Implementations§
impl Freeze for Variable
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