use crate::dataset::*;
use crate::graph::*;
use crate::source::*;
pub trait TripleSerializer {
type Error: std::error::Error + Send + Sync + 'static;
fn serialize_triples<TS>(
&mut self,
source: TS,
) -> StreamResult<&mut Self, TS::Error, Self::Error>
where
TS: TripleSource,
Self: Sized;
#[inline]
fn serialize_graph<G>(&mut self, graph: &G) -> StreamResult<&mut Self, G::Error, Self::Error>
where
G: Graph,
Self: Sized,
{
self.serialize_triples(&mut graph.triples())
}
}
pub trait QuadSerializer {
type Error: std::error::Error + Send + Sync + 'static;
fn serialize_quads<QS>(
&mut self,
source: QS,
) -> StreamResult<&mut Self, QS::Error, Self::Error>
where
QS: QuadSource,
Self: Sized;
#[inline]
fn serialize_dataset<D>(
&mut self,
dataset: &D,
) -> StreamResult<&mut Self, D::Error, Self::Error>
where
D: Dataset,
Self: Sized,
{
self.serialize_quads(&mut dataset.quads())
}
}
pub trait Stringifier {
fn as_utf8(&self) -> &[u8];
fn as_str(&self) -> &str {
unsafe { std::str::from_utf8_unchecked(self.as_utf8()) }
}
fn to_string(&self) -> String {
self.as_str().to_string()
}
}