use std::borrow::Cow;
use iri_rs::{Iri, IriBuf};
use crate::{BlankId, BlankIdBuf, CowId, CowLiteral, CowLocalTerm, CowTerm, Id, IdRef, Literal, LiteralRef, LocalTerm, LocalTermRef, Term, TermRef};
#[doc(hidden)]
pub mod __seal {
pub trait Sealed {}
}
pub trait IsSubject: __seal::Sealed {}
pub trait IsPredicate: __seal::Sealed {}
pub trait IsObject: __seal::Sealed {}
pub trait IsGraph: __seal::Sealed {}
pub trait Resource: IsSubject + IsPredicate + IsObject + IsGraph {}
impl<T: __seal::Sealed + ?Sized> __seal::Sealed for &T {}
impl<T: IsSubject + ?Sized> IsSubject for &T {}
impl<T: IsPredicate + ?Sized> IsPredicate for &T {}
impl<T: IsObject + ?Sized> IsObject for &T {}
impl<T: IsGraph + ?Sized> IsGraph for &T {}
impl<T: Resource + ?Sized> Resource for &T {}
impl<T: __seal::Sealed> __seal::Sealed for Option<T> {}
impl<T: IsSubject> IsSubject for Option<T> {}
impl<T: IsPredicate> IsPredicate for Option<T> {}
impl<T: IsObject> IsObject for Option<T> {}
impl<T: IsGraph> IsGraph for Option<T> {}
macro_rules! impl_iri_positions {
($t:ty) => {
impl __seal::Sealed for $t {}
impl IsSubject for $t {}
impl IsPredicate for $t {}
impl IsObject for $t {}
impl IsGraph for $t {}
};
}
impl_iri_positions!(IriBuf);
impl_iri_positions!(Iri<&'_ str>);
impl_iri_positions!(Cow<'_, IriBuf>);
macro_rules! impl_id_positions {
($t:ty) => {
impl __seal::Sealed for $t {}
impl IsSubject for $t {}
impl IsObject for $t {}
impl IsGraph for $t {}
};
}
impl_id_positions!(BlankIdBuf);
impl_id_positions!(BlankId);
impl_id_positions!(Cow<'_, BlankId>);
impl_id_positions!(Id);
impl_id_positions!(IdRef<'_>);
impl_id_positions!(CowId<'_>);
macro_rules! impl_obj_positions {
($t:ty) => {
impl __seal::Sealed for $t {}
impl IsObject for $t {}
};
}
impl_obj_positions!(Literal);
impl_obj_positions!(LiteralRef<'_>);
impl_obj_positions!(CowLiteral<'_>);
impl_obj_positions!(Term);
impl_obj_positions!(TermRef<'_>);
impl_obj_positions!(CowTerm<'_>);
impl_obj_positions!(LocalTerm);
impl_obj_positions!(LocalTermRef<'_>);
impl_obj_positions!(CowLocalTerm<'_>);
#[macro_export]
macro_rules! impl_resource {
($t:ty) => {
impl $crate::Resource for $t {}
impl $crate::__seal::Sealed for $t {}
impl $crate::IsSubject for $t {}
impl $crate::IsPredicate for $t {}
impl $crate::IsObject for $t {}
impl $crate::IsGraph for $t {}
};
}
impl_resource!(usize);
impl_resource!(u32);
impl_resource!(u64);
impl_resource!(i32);
impl_resource!(i64);
impl_resource!(String);
impl Resource for str {}
impl __seal::Sealed for str {}
impl IsSubject for str {}
impl IsPredicate for str {}
impl IsObject for str {}
impl IsGraph for str {}