pub enum Subject<I = IriBuf, B = BlankIdBuf> {
Blank(B),
Iri(I),
}Expand description
RDF Subject.
Either a blank node identifier or an IRI.
Hash implementation
It is guaranteed that the Hash implementation of Subject is
transparent, meaning that the hash of Term::Blank(id) the same as id
and the hash of Subject::Iri(iri) is the same as iri.
Variants§
Implementations§
source§impl<I, B> Subject<I, B>
impl<I, B> Subject<I, B>
pub fn is_blank(&self) -> bool
pub fn is_iri(&self) -> bool
pub fn as_blank(&self) -> Option<&B>
pub fn as_iri(&self) -> Option<&I>
sourcepub fn into_term<L>(self) -> Term<I, B, L>
pub fn into_term<L>(self) -> Term<I, B, L>
Examples found in repository?
src/lib.rs (line 81)
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
pub fn into_grdf(self) -> GrdfTriple {
Triple(self.0.into_term(), Term::Iri(self.1), self.2)
}
pub fn as_grdf(&self) -> GrdfTripleRef {
Triple(
self.0.as_term_ref(),
TermRef::Iri(self.1.as_iri()),
self.2.as_term_ref(),
)
}
}
impl<S, P, O> Triple<S, P, O> {
/// Creates a new triple.
pub fn new(subject: S, predicate: P, object: O) -> Self {
Self(subject, predicate, object)
}
/// Returns a reference to the subject of the triple,
/// the first component.
pub fn subject(&self) -> &S {
&self.0
}
/// Returns a mutable reference to the subject of the triple,
/// the first component.
pub fn subject_mut(&mut self) -> &mut S {
&mut self.0
}
/// Turns the triple into its subject,
/// the first component.
pub fn into_subject(self) -> S {
self.0
}
/// Returns a reference to the predicate of the triple,
/// the second component.
pub fn predicate(&self) -> &P {
&self.1
}
/// Returns a mutable reference to the predicate of the triple,
/// the second component.
pub fn predicate_mut(&mut self) -> &mut P {
&mut self.1
}
/// Turns the triple into its predicate,
/// the second component.
pub fn into_predicate(self) -> P {
self.1
}
/// Returns a reference to the object of the triple,
/// the third component.
pub fn object(&self) -> &O {
&self.2
}
/// Returns a mutable reference to the object of the triple,
/// the third component.
pub fn object_mut(&mut self) -> &mut O {
&mut self.2
}
/// Turns the triple into its object,
/// the third component.
pub fn into_object(self) -> O {
self.2
}
/// Turns the triple into a tuple
pub fn into_parts(self) -> (S, P, O) {
(self.0, self.1, self.2)
}
/// Maps the subject with the given function.
pub fn map_subject<U>(self, f: impl FnOnce(S) -> U) -> Triple<U, P, O> {
Triple(f(self.0), self.1, self.2)
}
/// Maps the subject with the given function.
pub fn map_predicate<U>(self, f: impl FnOnce(P) -> U) -> Triple<S, U, O> {
Triple(self.0, f(self.1), self.2)
}
/// Maps the subject with the given function.
pub fn map_object<U>(self, f: impl FnOnce(O) -> U) -> Triple<S, P, U> {
Triple(self.0, self.1, f(self.2))
}
}
impl<S, L> Triple<Subject, IriBuf, Object<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>> {
#[allow(clippy::type_complexity)]
pub fn inserted_into<V: VocabularyMut>(
&self,
vocabulary: &mut V,
) -> Triple<
Subject<V::Iri, V::BlankId>,
V::Iri,
Object<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
>
where
S: Clone,
L: Clone,
{
Triple(
self.0.inserted_into(vocabulary),
vocabulary.insert(self.1.as_iri()),
self.2.inserted_into(vocabulary),
)
}
#[allow(clippy::type_complexity)]
pub fn insert_into<V: VocabularyMut>(
self,
vocabulary: &mut V,
) -> Triple<
Subject<V::Iri, V::BlankId>,
V::Iri,
Object<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
> {
Triple(
self.0.insert_into(vocabulary),
vocabulary.insert(self.1.as_iri()),
self.2.insert_into(vocabulary),
)
}
}
impl<S, L>
Quad<
Term<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>,
Term<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>,
Term<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>,
>
{
#[allow(clippy::type_complexity)]
pub fn inserted_into<V: VocabularyMut>(
&self,
vocabulary: &mut V,
) -> Triple<
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
>
where
S: Clone,
L: Clone,
{
Triple(
self.0.inserted_into(vocabulary),
self.1.inserted_into(vocabulary),
self.2.inserted_into(vocabulary),
)
}
#[allow(clippy::type_complexity)]
pub fn insert_into<V: VocabularyMut>(
self,
vocabulary: &mut V,
) -> Triple<
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
> {
Triple(
self.0.insert_into(vocabulary),
self.1.insert_into(vocabulary),
self.2.insert_into(vocabulary),
)
}
}
impl<S: RdfDisplay, P: RdfDisplay, O: RdfDisplay> fmt::Display for Triple<S, P, O> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.rdf_display(),
self.1.rdf_display(),
self.2.rdf_display()
)
}
}
impl<S: RdfDisplay, P: RdfDisplay, O: RdfDisplay> RdfDisplay for Triple<S, P, O> {
fn rdf_fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.rdf_display(),
self.1.rdf_display(),
self.2.rdf_display()
)
}
}
#[cfg(feature = "contextual")]
impl<S: RdfDisplayWithContext<V>, P: RdfDisplayWithContext<V>, O: RdfDisplayWithContext<V>, V>
DisplayWithContext<V> for Triple<S, P, O>
{
fn fmt_with(&self, vocabulary: &V, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.with(vocabulary).rdf_display(),
self.1.with(vocabulary).rdf_display(),
self.2.with(vocabulary).rdf_display()
)
}
}
#[cfg(feature = "contextual")]
impl<S: RdfDisplayWithContext<V>, P: RdfDisplayWithContext<V>, O: RdfDisplayWithContext<V>, V>
RdfDisplayWithContext<V> for Triple<S, P, O>
{
fn rdf_fmt_with(&self, vocabulary: &V, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.with(vocabulary).rdf_display(),
self.1.with(vocabulary).rdf_display(),
self.2.with(vocabulary).rdf_display()
)
}
}
/// RDF triple reference.
pub type TripleRef<'a> = Triple<SubjectRef<'a>, Iri<'a>, ObjectRef<'a>>;
/// gRDF triple.
pub type GrdfTriple = Triple<Term, Term, Term>;
/// gRDF triple reference.
pub type GrdfTripleRef<'a> = Triple<TermRef<'a>, TermRef<'a>, TermRef<'a>>;
/// RDF quad.
#[derive(Clone, Copy, Eq, Ord, Hash, Debug)]
#[cfg_attr(
feature = "meta",
derive(
StrippedPartialEq,
StrippedEq,
StrippedPartialOrd,
StrippedOrd,
StrippedHash
)
)]
pub struct Quad<S = Subject, P = IriBuf, O = Object, G = GraphLabel>(
pub S,
pub P,
pub O,
pub Option<G>,
);
impl Quad {
pub fn into_grdf(self) -> GrdfQuad {
Quad(
self.0.into_term(),
Term::Iri(self.1),
self.2,
self.3.map(GraphLabel::into_term),
)
}pub fn as_str(&self) -> &strwhere
I: AsRef<str>,
B: AsRef<str>,
source§impl Subject
impl Subject
sourcepub fn as_subject_ref(&self) -> SubjectRef<'_>
pub fn as_subject_ref(&self) -> SubjectRef<'_>
Examples found in repository?
src/term.rs (line 371)
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
pub fn as_graph_label_ref(&self) -> GraphLabelRef {
self.as_subject_ref()
}
pub fn as_term_ref(&self) -> TermRef {
match self {
Self::Blank(id) => TermRef::Blank(id),
Self::Iri(iri) => TermRef::Iri(iri.as_iri()),
}
}
pub fn inserted_into<V: VocabularyMut>(
&self,
vocabulary: &mut V,
) -> Subject<V::Iri, V::BlankId> {
match self {
Self::Blank(b) => Subject::Blank(vocabulary.insert_blank_id(b.as_blank_id_ref())),
Self::Iri(i) => Subject::Iri(vocabulary.insert(i.as_iri())),
}
}
pub fn insert_into<V: VocabularyMut>(self, vocabulary: &mut V) -> Subject<V::Iri, V::BlankId> {
match self {
Self::Blank(b) => Subject::Blank(vocabulary.insert_blank_id(b.as_blank_id_ref())),
Self::Iri(i) => Subject::Iri(vocabulary.insert(i.as_iri())),
}
}
}
impl<I: Hash, B: Hash> Hash for Subject<I, B> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
match self {
Self::Blank(id) => id.hash(state),
Self::Iri(i) => i.hash(state),
}
}
}
#[cfg(feature = "meta")]
impl<I: Hash, B: Hash> locspan::StrippedHash for Subject<I, B> {
fn stripped_hash<H: std::hash::Hasher>(&self, state: &mut H) {
match self {
Self::Blank(id) => id.hash(state),
Self::Iri(i) => i.hash(state),
}
}
}
impl<I1: PartialEq<I2>, B1: PartialEq<B2>, I2, B2> PartialEq<Subject<I2, B2>> for Subject<I1, B1> {
fn eq(&self, other: &Subject<I2, B2>) -> bool {
match (self, other) {
(Self::Blank(a), Subject::Blank(b)) => a == b,
(Self::Iri(a), Subject::Iri(b)) => a == b,
_ => false,
}
}
}
impl<I1: PartialOrd<I2>, B1: PartialOrd<B2>, I2, B2> PartialOrd<Subject<I2, B2>>
for Subject<I1, B1>
{
fn partial_cmp(&self, other: &Subject<I2, B2>) -> Option<Ordering> {
match (self, other) {
(Self::Blank(a), Subject::Blank(b)) => a.partial_cmp(b),
(Self::Blank(_), _) => Some(Ordering::Less),
(Self::Iri(a), Subject::Iri(b)) => a.partial_cmp(b),
_ => Some(Ordering::Greater),
}
}
}
impl<I: fmt::Display, B: fmt::Display> fmt::Display for Subject<I, B> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::Blank(id) => id.fmt(f),
Self::Iri(iri) => write!(f, "{}", iri),
}
}
}
#[cfg(feature = "contextual")]
impl<I, B, V: crate::Vocabulary<Iri = I, BlankId = B>> DisplayWithContext<V> for Subject<I, B> {
fn fmt_with(&self, vocabulary: &V, f: &mut fmt::Formatter) -> fmt::Result {
use fmt::Display;
match self {
Self::Blank(id) => vocabulary.blank_id(id).unwrap().fmt(f),
Self::Iri(iri) => write!(f, "{}", vocabulary.iri(iri).unwrap()),
}
}
}
impl<I: fmt::Display, B: fmt::Display> RdfDisplay for Subject<I, B> {
fn rdf_fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::Blank(id) => id.fmt(f),
Self::Iri(iri) => write!(f, "<{}>", iri),
}
}
}
#[cfg(feature = "contextual")]
impl<I, B, V: crate::Vocabulary<Iri = I, BlankId = B>> crate::RdfDisplayWithContext<V>
for Subject<I, B>
{
fn rdf_fmt_with(&self, vocabulary: &V, f: &mut fmt::Formatter) -> fmt::Result {
use fmt::Display;
match self {
Self::Blank(id) => vocabulary.blank_id(id).unwrap().fmt(f),
Self::Iri(iri) => write!(f, "<{}>", vocabulary.iri(iri).unwrap()),
}
}
}
#[cfg(feature = "contextual")]
impl<I, B, V: crate::Vocabulary<Iri = I, BlankId = B>> AsRefWithContext<str, V> for Subject<I, B> {
fn as_ref_with<'a>(&'a self, vocabulary: &'a V) -> &'a str {
match self {
Self::Blank(b) => vocabulary.blank_id(b).unwrap().as_str(),
Self::Iri(i) => vocabulary.iri(i).unwrap().into_str(),
}
}
}
pub type SubjectRef<'a> = Subject<Iri<'a>, &'a BlankId>;
impl<'a> SubjectRef<'a> {
pub fn into_owned(self) -> Subject {
match self {
Self::Iri(iri) => Subject::Iri(iri.to_owned()),
Self::Blank(b) => Subject::Blank(b.to_owned()),
}
}
}
impl<'a> From<&'a Subject> for SubjectRef<'a> {
fn from(t: &'a Subject) -> Self {
t.as_subject_ref()
}More examples
src/lib.rs (line 713)
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778
pub fn as_quad_ref(&self) -> QuadRef {
Quad(
self.0.as_subject_ref(),
self.1.as_iri(),
self.2.as_object_ref(),
self.3.as_ref().map(GraphLabel::as_graph_label_ref),
)
}
}
impl<'a> From<QuadRef<'a>> for Quad {
#[inline(always)]
fn from(q: QuadRef<'a>) -> Self {
q.into_owned()
}
}
impl GrdfQuad {
#[inline(always)]
pub fn as_grdf_quad_ref(&self) -> GrdfQuadRef {
Quad(
self.0.as_term_ref(),
self.1.as_term_ref(),
self.2.as_term_ref(),
self.3.as_ref().map(Term::as_term_ref),
)
}
}
impl<'a> From<GrdfQuadRef<'a>> for GrdfQuad {
#[inline(always)]
fn from(q: GrdfQuadRef<'a>) -> Self {
q.into_owned()
}
}
/// RDF quad reference.
pub type QuadRef<'a> = Quad<SubjectRef<'a>, Iri<'a>, ObjectRef<'a>, GraphLabelRef<'a>>;
impl<'a> QuadRef<'a> {
#[inline(always)]
pub fn into_owned(self) -> Quad {
Quad(
self.0.into_owned(),
self.1.to_owned(),
self.2.into_owned(),
self.3.map(GraphLabelRef::into_owned),
)
}
}
impl<'a> From<&'a Quad> for QuadRef<'a> {
#[inline(always)]
fn from(q: &'a Quad) -> Self {
q.as_quad_ref()
}
}
impl<'a> From<Quad<&'a Subject, &'a IriBuf, &'a Object, &'a GraphLabel>> for QuadRef<'a> {
#[inline(always)]
fn from(Quad(s, p, o, g): Quad<&'a Subject, &'a IriBuf, &'a Object, &'a GraphLabel>) -> Self {
Quad(
s.as_subject_ref(),
p.as_iri(),
o.as_object_ref(),
g.map(GraphLabel::as_graph_label_ref),
)
}pub fn as_graph_label_ref(&self) -> GraphLabelRef<'_>
sourcepub fn as_term_ref(&self) -> TermRef<'_>
pub fn as_term_ref(&self) -> TermRef<'_>
Examples found in repository?
src/lib.rs (line 86)
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
pub fn as_grdf(&self) -> GrdfTripleRef {
Triple(
self.0.as_term_ref(),
TermRef::Iri(self.1.as_iri()),
self.2.as_term_ref(),
)
}
}
impl<S, P, O> Triple<S, P, O> {
/// Creates a new triple.
pub fn new(subject: S, predicate: P, object: O) -> Self {
Self(subject, predicate, object)
}
/// Returns a reference to the subject of the triple,
/// the first component.
pub fn subject(&self) -> &S {
&self.0
}
/// Returns a mutable reference to the subject of the triple,
/// the first component.
pub fn subject_mut(&mut self) -> &mut S {
&mut self.0
}
/// Turns the triple into its subject,
/// the first component.
pub fn into_subject(self) -> S {
self.0
}
/// Returns a reference to the predicate of the triple,
/// the second component.
pub fn predicate(&self) -> &P {
&self.1
}
/// Returns a mutable reference to the predicate of the triple,
/// the second component.
pub fn predicate_mut(&mut self) -> &mut P {
&mut self.1
}
/// Turns the triple into its predicate,
/// the second component.
pub fn into_predicate(self) -> P {
self.1
}
/// Returns a reference to the object of the triple,
/// the third component.
pub fn object(&self) -> &O {
&self.2
}
/// Returns a mutable reference to the object of the triple,
/// the third component.
pub fn object_mut(&mut self) -> &mut O {
&mut self.2
}
/// Turns the triple into its object,
/// the third component.
pub fn into_object(self) -> O {
self.2
}
/// Turns the triple into a tuple
pub fn into_parts(self) -> (S, P, O) {
(self.0, self.1, self.2)
}
/// Maps the subject with the given function.
pub fn map_subject<U>(self, f: impl FnOnce(S) -> U) -> Triple<U, P, O> {
Triple(f(self.0), self.1, self.2)
}
/// Maps the subject with the given function.
pub fn map_predicate<U>(self, f: impl FnOnce(P) -> U) -> Triple<S, U, O> {
Triple(self.0, f(self.1), self.2)
}
/// Maps the subject with the given function.
pub fn map_object<U>(self, f: impl FnOnce(O) -> U) -> Triple<S, P, U> {
Triple(self.0, self.1, f(self.2))
}
}
impl<S, L> Triple<Subject, IriBuf, Object<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>> {
#[allow(clippy::type_complexity)]
pub fn inserted_into<V: VocabularyMut>(
&self,
vocabulary: &mut V,
) -> Triple<
Subject<V::Iri, V::BlankId>,
V::Iri,
Object<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
>
where
S: Clone,
L: Clone,
{
Triple(
self.0.inserted_into(vocabulary),
vocabulary.insert(self.1.as_iri()),
self.2.inserted_into(vocabulary),
)
}
#[allow(clippy::type_complexity)]
pub fn insert_into<V: VocabularyMut>(
self,
vocabulary: &mut V,
) -> Triple<
Subject<V::Iri, V::BlankId>,
V::Iri,
Object<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
> {
Triple(
self.0.insert_into(vocabulary),
vocabulary.insert(self.1.as_iri()),
self.2.insert_into(vocabulary),
)
}
}
impl<S, L>
Quad<
Term<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>,
Term<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>,
Term<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>,
>
{
#[allow(clippy::type_complexity)]
pub fn inserted_into<V: VocabularyMut>(
&self,
vocabulary: &mut V,
) -> Triple<
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
>
where
S: Clone,
L: Clone,
{
Triple(
self.0.inserted_into(vocabulary),
self.1.inserted_into(vocabulary),
self.2.inserted_into(vocabulary),
)
}
#[allow(clippy::type_complexity)]
pub fn insert_into<V: VocabularyMut>(
self,
vocabulary: &mut V,
) -> Triple<
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
> {
Triple(
self.0.insert_into(vocabulary),
self.1.insert_into(vocabulary),
self.2.insert_into(vocabulary),
)
}
}
impl<S: RdfDisplay, P: RdfDisplay, O: RdfDisplay> fmt::Display for Triple<S, P, O> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.rdf_display(),
self.1.rdf_display(),
self.2.rdf_display()
)
}
}
impl<S: RdfDisplay, P: RdfDisplay, O: RdfDisplay> RdfDisplay for Triple<S, P, O> {
fn rdf_fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.rdf_display(),
self.1.rdf_display(),
self.2.rdf_display()
)
}
}
#[cfg(feature = "contextual")]
impl<S: RdfDisplayWithContext<V>, P: RdfDisplayWithContext<V>, O: RdfDisplayWithContext<V>, V>
DisplayWithContext<V> for Triple<S, P, O>
{
fn fmt_with(&self, vocabulary: &V, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.with(vocabulary).rdf_display(),
self.1.with(vocabulary).rdf_display(),
self.2.with(vocabulary).rdf_display()
)
}
}
#[cfg(feature = "contextual")]
impl<S: RdfDisplayWithContext<V>, P: RdfDisplayWithContext<V>, O: RdfDisplayWithContext<V>, V>
RdfDisplayWithContext<V> for Triple<S, P, O>
{
fn rdf_fmt_with(&self, vocabulary: &V, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.with(vocabulary).rdf_display(),
self.1.with(vocabulary).rdf_display(),
self.2.with(vocabulary).rdf_display()
)
}
}
/// RDF triple reference.
pub type TripleRef<'a> = Triple<SubjectRef<'a>, Iri<'a>, ObjectRef<'a>>;
/// gRDF triple.
pub type GrdfTriple = Triple<Term, Term, Term>;
/// gRDF triple reference.
pub type GrdfTripleRef<'a> = Triple<TermRef<'a>, TermRef<'a>, TermRef<'a>>;
/// RDF quad.
#[derive(Clone, Copy, Eq, Ord, Hash, Debug)]
#[cfg_attr(
feature = "meta",
derive(
StrippedPartialEq,
StrippedEq,
StrippedPartialOrd,
StrippedOrd,
StrippedHash
)
)]
pub struct Quad<S = Subject, P = IriBuf, O = Object, G = GraphLabel>(
pub S,
pub P,
pub O,
pub Option<G>,
);
impl Quad {
pub fn into_grdf(self) -> GrdfQuad {
Quad(
self.0.into_term(),
Term::Iri(self.1),
self.2,
self.3.map(GraphLabel::into_term),
)
}
pub fn as_grdf(&self) -> GrdfQuadRef {
Quad(
self.0.as_term_ref(),
TermRef::Iri(self.1.as_iri()),
self.2.as_term_ref(),
self.3.as_ref().map(GraphLabel::as_term_ref),
)
}sourcepub fn inserted_into<V: VocabularyMut>(
&self,
vocabulary: &mut V
) -> Subject<V::Iri, V::BlankId>
pub fn inserted_into<V: VocabularyMut>(
&self,
vocabulary: &mut V
) -> Subject<V::Iri, V::BlankId>
Examples found in repository?
src/lib.rs (line 189)
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
pub fn inserted_into<V: VocabularyMut>(
&self,
vocabulary: &mut V,
) -> Triple<
Subject<V::Iri, V::BlankId>,
V::Iri,
Object<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
>
where
S: Clone,
L: Clone,
{
Triple(
self.0.inserted_into(vocabulary),
vocabulary.insert(self.1.as_iri()),
self.2.inserted_into(vocabulary),
)
}
#[allow(clippy::type_complexity)]
pub fn insert_into<V: VocabularyMut>(
self,
vocabulary: &mut V,
) -> Triple<
Subject<V::Iri, V::BlankId>,
V::Iri,
Object<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
> {
Triple(
self.0.insert_into(vocabulary),
vocabulary.insert(self.1.as_iri()),
self.2.insert_into(vocabulary),
)
}
}
impl<S, L>
Quad<
Term<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>,
Term<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>,
Term<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>,
>
{
#[allow(clippy::type_complexity)]
pub fn inserted_into<V: VocabularyMut>(
&self,
vocabulary: &mut V,
) -> Triple<
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
>
where
S: Clone,
L: Clone,
{
Triple(
self.0.inserted_into(vocabulary),
self.1.inserted_into(vocabulary),
self.2.inserted_into(vocabulary),
)
}
#[allow(clippy::type_complexity)]
pub fn insert_into<V: VocabularyMut>(
self,
vocabulary: &mut V,
) -> Triple<
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
> {
Triple(
self.0.insert_into(vocabulary),
self.1.insert_into(vocabulary),
self.2.insert_into(vocabulary),
)
}
}
impl<S: RdfDisplay, P: RdfDisplay, O: RdfDisplay> fmt::Display for Triple<S, P, O> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.rdf_display(),
self.1.rdf_display(),
self.2.rdf_display()
)
}
}
impl<S: RdfDisplay, P: RdfDisplay, O: RdfDisplay> RdfDisplay for Triple<S, P, O> {
fn rdf_fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.rdf_display(),
self.1.rdf_display(),
self.2.rdf_display()
)
}
}
#[cfg(feature = "contextual")]
impl<S: RdfDisplayWithContext<V>, P: RdfDisplayWithContext<V>, O: RdfDisplayWithContext<V>, V>
DisplayWithContext<V> for Triple<S, P, O>
{
fn fmt_with(&self, vocabulary: &V, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.with(vocabulary).rdf_display(),
self.1.with(vocabulary).rdf_display(),
self.2.with(vocabulary).rdf_display()
)
}
}
#[cfg(feature = "contextual")]
impl<S: RdfDisplayWithContext<V>, P: RdfDisplayWithContext<V>, O: RdfDisplayWithContext<V>, V>
RdfDisplayWithContext<V> for Triple<S, P, O>
{
fn rdf_fmt_with(&self, vocabulary: &V, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.with(vocabulary).rdf_display(),
self.1.with(vocabulary).rdf_display(),
self.2.with(vocabulary).rdf_display()
)
}
}
/// RDF triple reference.
pub type TripleRef<'a> = Triple<SubjectRef<'a>, Iri<'a>, ObjectRef<'a>>;
/// gRDF triple.
pub type GrdfTriple = Triple<Term, Term, Term>;
/// gRDF triple reference.
pub type GrdfTripleRef<'a> = Triple<TermRef<'a>, TermRef<'a>, TermRef<'a>>;
/// RDF quad.
#[derive(Clone, Copy, Eq, Ord, Hash, Debug)]
#[cfg_attr(
feature = "meta",
derive(
StrippedPartialEq,
StrippedEq,
StrippedPartialOrd,
StrippedOrd,
StrippedHash
)
)]
pub struct Quad<S = Subject, P = IriBuf, O = Object, G = GraphLabel>(
pub S,
pub P,
pub O,
pub Option<G>,
);
impl Quad {
pub fn into_grdf(self) -> GrdfQuad {
Quad(
self.0.into_term(),
Term::Iri(self.1),
self.2,
self.3.map(GraphLabel::into_term),
)
}
pub fn as_grdf(&self) -> GrdfQuadRef {
Quad(
self.0.as_term_ref(),
TermRef::Iri(self.1.as_iri()),
self.2.as_term_ref(),
self.3.as_ref().map(GraphLabel::as_term_ref),
)
}
}
impl<S, L> Quad<Subject, IriBuf, Object<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>, GraphLabel> {
#[allow(clippy::type_complexity)]
pub fn inserted_into<V: VocabularyMut>(
&self,
vocabulary: &mut V,
) -> Quad<
Subject<V::Iri, V::BlankId>,
V::Iri,
Object<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
GraphLabel<V::Iri, V::BlankId>,
>
where
S: Clone,
L: Clone,
{
Quad(
self.0.inserted_into(vocabulary),
vocabulary.insert(self.1.as_iri()),
self.2.inserted_into(vocabulary),
self.3.as_ref().map(|g| g.inserted_into(vocabulary)),
)
}sourcepub fn insert_into<V: VocabularyMut>(
self,
vocabulary: &mut V
) -> Subject<V::Iri, V::BlankId>
pub fn insert_into<V: VocabularyMut>(
self,
vocabulary: &mut V
) -> Subject<V::Iri, V::BlankId>
Examples found in repository?
src/lib.rs (line 205)
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
pub fn insert_into<V: VocabularyMut>(
self,
vocabulary: &mut V,
) -> Triple<
Subject<V::Iri, V::BlankId>,
V::Iri,
Object<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
> {
Triple(
self.0.insert_into(vocabulary),
vocabulary.insert(self.1.as_iri()),
self.2.insert_into(vocabulary),
)
}
}
impl<S, L>
Quad<
Term<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>,
Term<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>,
Term<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>,
>
{
#[allow(clippy::type_complexity)]
pub fn inserted_into<V: VocabularyMut>(
&self,
vocabulary: &mut V,
) -> Triple<
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
>
where
S: Clone,
L: Clone,
{
Triple(
self.0.inserted_into(vocabulary),
self.1.inserted_into(vocabulary),
self.2.inserted_into(vocabulary),
)
}
#[allow(clippy::type_complexity)]
pub fn insert_into<V: VocabularyMut>(
self,
vocabulary: &mut V,
) -> Triple<
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
Term<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
> {
Triple(
self.0.insert_into(vocabulary),
self.1.insert_into(vocabulary),
self.2.insert_into(vocabulary),
)
}
}
impl<S: RdfDisplay, P: RdfDisplay, O: RdfDisplay> fmt::Display for Triple<S, P, O> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.rdf_display(),
self.1.rdf_display(),
self.2.rdf_display()
)
}
}
impl<S: RdfDisplay, P: RdfDisplay, O: RdfDisplay> RdfDisplay for Triple<S, P, O> {
fn rdf_fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.rdf_display(),
self.1.rdf_display(),
self.2.rdf_display()
)
}
}
#[cfg(feature = "contextual")]
impl<S: RdfDisplayWithContext<V>, P: RdfDisplayWithContext<V>, O: RdfDisplayWithContext<V>, V>
DisplayWithContext<V> for Triple<S, P, O>
{
fn fmt_with(&self, vocabulary: &V, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.with(vocabulary).rdf_display(),
self.1.with(vocabulary).rdf_display(),
self.2.with(vocabulary).rdf_display()
)
}
}
#[cfg(feature = "contextual")]
impl<S: RdfDisplayWithContext<V>, P: RdfDisplayWithContext<V>, O: RdfDisplayWithContext<V>, V>
RdfDisplayWithContext<V> for Triple<S, P, O>
{
fn rdf_fmt_with(&self, vocabulary: &V, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {}",
self.0.with(vocabulary).rdf_display(),
self.1.with(vocabulary).rdf_display(),
self.2.with(vocabulary).rdf_display()
)
}
}
/// RDF triple reference.
pub type TripleRef<'a> = Triple<SubjectRef<'a>, Iri<'a>, ObjectRef<'a>>;
/// gRDF triple.
pub type GrdfTriple = Triple<Term, Term, Term>;
/// gRDF triple reference.
pub type GrdfTripleRef<'a> = Triple<TermRef<'a>, TermRef<'a>, TermRef<'a>>;
/// RDF quad.
#[derive(Clone, Copy, Eq, Ord, Hash, Debug)]
#[cfg_attr(
feature = "meta",
derive(
StrippedPartialEq,
StrippedEq,
StrippedPartialOrd,
StrippedOrd,
StrippedHash
)
)]
pub struct Quad<S = Subject, P = IriBuf, O = Object, G = GraphLabel>(
pub S,
pub P,
pub O,
pub Option<G>,
);
impl Quad {
pub fn into_grdf(self) -> GrdfQuad {
Quad(
self.0.into_term(),
Term::Iri(self.1),
self.2,
self.3.map(GraphLabel::into_term),
)
}
pub fn as_grdf(&self) -> GrdfQuadRef {
Quad(
self.0.as_term_ref(),
TermRef::Iri(self.1.as_iri()),
self.2.as_term_ref(),
self.3.as_ref().map(GraphLabel::as_term_ref),
)
}
}
impl<S, L> Quad<Subject, IriBuf, Object<IriBuf, BlankIdBuf, Literal<S, IriBuf, L>>, GraphLabel> {
#[allow(clippy::type_complexity)]
pub fn inserted_into<V: VocabularyMut>(
&self,
vocabulary: &mut V,
) -> Quad<
Subject<V::Iri, V::BlankId>,
V::Iri,
Object<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
GraphLabel<V::Iri, V::BlankId>,
>
where
S: Clone,
L: Clone,
{
Quad(
self.0.inserted_into(vocabulary),
vocabulary.insert(self.1.as_iri()),
self.2.inserted_into(vocabulary),
self.3.as_ref().map(|g| g.inserted_into(vocabulary)),
)
}
#[allow(clippy::type_complexity)]
pub fn insert_into<V: VocabularyMut>(
self,
vocabulary: &mut V,
) -> Quad<
Subject<V::Iri, V::BlankId>,
V::Iri,
Object<V::Iri, V::BlankId, Literal<S, V::Iri, L>>,
GraphLabel<V::Iri, V::BlankId>,
> {
Quad(
self.0.insert_into(vocabulary),
vocabulary.insert(self.1.as_iri()),
self.2.insert_into(vocabulary),
self.3.map(|g| g.insert_into(vocabulary)),
)
}Trait Implementations§
source§impl<'a> From<&'a Subject<IriBuf, BlankIdBuf>> for SubjectRef<'a>
impl<'a> From<&'a Subject<IriBuf, BlankIdBuf>> for SubjectRef<'a>
source§impl<I: Ord, B: Ord> Ord for Subject<I, B>
impl<I: Ord, B: Ord> Ord for Subject<I, B>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<I1: PartialEq<I2>, B1: PartialEq<B2>, I2, B2> PartialEq<Subject<I2, B2>> for Subject<I1, B1>
impl<I1: PartialEq<I2>, B1: PartialEq<B2>, I2, B2> PartialEq<Subject<I2, B2>> for Subject<I1, B1>
source§impl<I1: PartialOrd<I2>, B1: PartialOrd<B2>, I2, B2> PartialOrd<Subject<I2, B2>> for Subject<I1, B1>
impl<I1: PartialOrd<I2>, B1: PartialOrd<B2>, I2, B2> PartialOrd<Subject<I2, B2>> for Subject<I1, B1>
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 more