pub struct BlankNode(_);
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<Self, BlankNodeIdParseError>
pub fn new(id: impl Into<String>) -> Result<Self, 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>) -> Self
pub fn new_unchecked(id: impl Into<String>) -> Self
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) -> Self
pub fn new_from_unique_id(id: u128) -> Self
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() -> Self
fn default() -> Self
Builds a new RDF blank node with a unique id.
source§impl<'a> From<&'a BlankNode> for BlankNodeRef<'a>
impl<'a> From<&'a BlankNode> for BlankNodeRef<'a>
source§impl<'a> From<&'a BlankNode> for GraphNameRef<'a>
impl<'a> From<&'a BlankNode> for GraphNameRef<'a>
source§impl<'a> From<&'a BlankNode> for NamedOrBlankNodeRef<'a>
impl<'a> From<&'a BlankNode> for NamedOrBlankNodeRef<'a>
source§impl<'a> From<&'a BlankNode> for SubjectRef<'a>
impl<'a> From<&'a BlankNode> for SubjectRef<'a>
source§impl From<BlankNode> for NamedOrBlankNode
impl From<BlankNode> for NamedOrBlankNode
source§impl<'a> From<BlankNodeRef<'a>> for BlankNode
impl<'a> From<BlankNodeRef<'a>> for BlankNode
source§fn from(node: BlankNodeRef<'a>) -> Self
fn from(node: BlankNodeRef<'a>) -> Self
source§impl FromStr for BlankNode
impl FromStr for BlankNode
source§fn from_str(s: &str) -> Result<Self, TermParseError>
fn from_str(s: &str) -> Result<Self, TermParseError>
Parses a blank node from its NTriples and Turtle serialization
use oxrdf::BlankNode;
use std::str::FromStr;
assert_eq!(BlankNode::from_str("_:ex").unwrap(), BlankNode::new("ex").unwrap())
§type Err = TermParseError
type Err = TermParseError
source§impl PartialEq<BlankNode> for BlankNode
impl PartialEq<BlankNode> for BlankNode
source§impl PartialEq<BlankNode> for BlankNodeRef<'_>
impl PartialEq<BlankNode> for BlankNodeRef<'_>
source§impl PartialEq<BlankNodeRef<'_>> for BlankNode
impl PartialEq<BlankNodeRef<'_>> for BlankNode
source§fn eq(&self, other: &BlankNodeRef<'_>) -> bool
fn eq(&self, other: &BlankNodeRef<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.