pub struct TokioAsyncWriterJsonLdSerializer<W: AsyncWrite + Unpin> { /* private fields */ }
Available on crate feature
async-tokio
only.Expand description
Serializes a JSON-LD file to a AsyncWrite
implementation.
Can be built using JsonLdSerializer::for_tokio_async_writer
.
use oxrdf::{NamedNodeRef, QuadRef, LiteralRef, GraphNameRef};
use oxrdf::vocab::rdf;
use oxjsonld::JsonLdSerializer;
let mut serializer = JsonLdSerializer::new().with_prefix("schema", "http://schema.org/")?.for_tokio_async_writer(Vec::new());
serializer.serialize_quad(QuadRef::new(
NamedNodeRef::new("http://example.com#me")?,
rdf::TYPE,
NamedNodeRef::new("http://schema.org/Person")?,
GraphNameRef::DefaultGraph
)).await?;
serializer.serialize_quad(QuadRef::new(
NamedNodeRef::new("http://example.com#me")?,
NamedNodeRef::new("http://schema.org/name")?,
LiteralRef::new_language_tagged_literal_unchecked("Foo Bar", "en"),
GraphNameRef::DefaultGraph
)).await?;
assert_eq!(
b"{\"@context\":{\"schema\":\"http://schema.org/\"},\"@graph\":[{\"@id\":\"http://example.com#me\",\"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\":[{\"@id\":\"http://schema.org/Person\"}],\"http://schema.org/name\":[{\"@language\":\"en\",\"@value\":\"Foo Bar\"}]}]}",
serializer.finish().await?.as_slice()
);
Implementations§
Source§impl<W: AsyncWrite + Unpin> TokioAsyncWriterJsonLdSerializer<W>
impl<W: AsyncWrite + Unpin> TokioAsyncWriterJsonLdSerializer<W>
Auto Trait Implementations§
impl<W> Freeze for TokioAsyncWriterJsonLdSerializer<W>where
W: Freeze,
impl<W> RefUnwindSafe for TokioAsyncWriterJsonLdSerializer<W>where
W: RefUnwindSafe,
impl<W> Send for TokioAsyncWriterJsonLdSerializer<W>where
W: Send,
impl<W> Sync for TokioAsyncWriterJsonLdSerializer<W>where
W: Sync,
impl<W> Unpin for TokioAsyncWriterJsonLdSerializer<W>
impl<W> UnwindSafe for TokioAsyncWriterJsonLdSerializer<W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more