pub struct BlankNode(/* private fields */);
Expand description
An owned RDF blank node.
The common way to create a new blank node is to use the BlankNode::default()
function.
It is also possible to create a blank node from a blank node identifier using the BlankNode::new()
function.
The blank node identifier must be valid according to N-Triples, Turtle, and SPARQL grammars.
The default string formatter is returning an N-Triples, Turtle, and SPARQL compatible representation:
use oxrdf::BlankNode;
assert_eq!("_:a122", BlankNode::new("a122")?.to_string());
Implementations§
Source§impl BlankNode
impl BlankNode
Sourcepub fn new(id: impl Into<String>) -> Result<BlankNode, BlankNodeIdParseError>
pub fn new(id: impl Into<String>) -> Result<BlankNode, BlankNodeIdParseError>
Creates a blank node from a unique identifier.
The blank node identifier must be valid according to N-Triples, Turtle, and SPARQL grammars.
In most cases, it is much more convenient to create a blank node using BlankNode::default()
that creates a random ID that could be easily inlined by Oxigraph stores.
Sourcepub fn new_unchecked(id: impl Into<String>) -> BlankNode
pub fn new_unchecked(id: impl Into<String>) -> BlankNode
Creates a blank node from a unique identifier without validation.
It is the caller’s responsibility to ensure that id
is a valid blank node identifier
according to N-Triples, Turtle, and SPARQL grammars.
BlankNode::new()
is a safe version of this constructor and should be used for untrusted data.
Sourcepub fn new_from_unique_id(id: u128) -> BlankNode
pub fn new_from_unique_id(id: u128) -> BlankNode
Creates a blank node from a unique numerical id.
In most cases, it is much more convenient to create a blank node using BlankNode::default()
.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Returns the underlying ID of this blank node.
pub fn as_ref(&self) -> BlankNodeRef<'_>
Trait Implementations§
Source§impl Default for BlankNode
impl Default for BlankNode
Source§fn default() -> BlankNode
fn default() -> BlankNode
Builds a new RDF blank node with a unique id.
Source§impl From<BlankNode> for TermPattern
impl From<BlankNode> for TermPattern
Source§impl<'a> From<BlankNodeRef<'a>> for BlankNode
impl<'a> From<BlankNodeRef<'a>> for BlankNode
Source§fn from(node: BlankNodeRef<'a>) -> BlankNode
fn from(node: BlankNodeRef<'a>) -> BlankNode
Source§impl FromStr for BlankNode
impl FromStr for BlankNode
Source§fn from_str(s: &str) -> Result<BlankNode, <BlankNode as FromStr>::Err>
fn from_str(s: &str) -> Result<BlankNode, <BlankNode as FromStr>::Err>
Parses a blank node from its NTriples serialization
use oxrdf::BlankNode;
use std::str::FromStr;
assert_eq!(BlankNode::from_str("_:ex")?, BlankNode::new("ex")?);