I/O adds extra #[must_use] annotations

pull/612/head
Tpt 1 year ago committed by Thomas Tanon
parent 570f21748d
commit d44f9bee7a
  1. 5
      lib/oxrdfio/src/parser.rs
  2. 1
      lib/oxrdfio/src/serializer.rs
  3. 3
      lib/oxrdfxml/src/parser.rs
  4. 3
      lib/oxrdfxml/src/serializer.rs
  5. 3
      lib/oxttl/src/n3.rs
  6. 7
      lib/oxttl/src/nquads.rs
  7. 7
      lib/oxttl/src/ntriples.rs
  8. 7
      lib/oxttl/src/trig.rs
  9. 7
      lib/oxttl/src/turtle.rs

@ -53,6 +53,7 @@ use tokio::io::AsyncRead;
/// assert_eq!(quads[0].subject.to_string(), "<http://example.com/s>"); /// assert_eq!(quads[0].subject.to_string(), "<http://example.com/s>");
/// # std::io::Result::Ok(()) /// # std::io::Result::Ok(())
/// ``` /// ```
#[must_use]
pub struct RdfParser { pub struct RdfParser {
inner: RdfParserKind, inner: RdfParserKind,
default_graph: GraphName, default_graph: GraphName,
@ -72,7 +73,6 @@ enum RdfParserKind {
impl RdfParser { impl RdfParser {
/// Builds a parser for the given format. /// Builds a parser for the given format.
#[inline] #[inline]
#[must_use]
pub fn from_format(format: RdfFormat) -> Self { pub fn from_format(format: RdfFormat) -> Self {
Self { Self {
inner: match format { inner: match format {
@ -172,7 +172,6 @@ impl RdfParser {
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[inline] #[inline]
#[must_use]
pub fn with_default_graph(self, default_graph: impl Into<GraphName>) -> Self { pub fn with_default_graph(self, default_graph: impl Into<GraphName>) -> Self {
Self { Self {
inner: self.inner, inner: self.inner,
@ -195,7 +194,6 @@ impl RdfParser {
/// assert!(parser.parse_read(file.as_bytes()).next().unwrap().is_err()); /// assert!(parser.parse_read(file.as_bytes()).next().unwrap().is_err());
/// ``` /// ```
#[inline] #[inline]
#[must_use]
pub fn without_named_graphs(self) -> Self { pub fn without_named_graphs(self) -> Self {
Self { Self {
inner: self.inner, inner: self.inner,
@ -224,7 +222,6 @@ impl RdfParser {
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[inline] #[inline]
#[must_use]
pub fn rename_blank_nodes(self) -> Self { pub fn rename_blank_nodes(self) -> Self {
Self { Self {
inner: self.inner, inner: self.inner,

@ -48,6 +48,7 @@ use tokio::io::AsyncWrite;
/// assert_eq!(buffer.as_slice(), "<http://example.com/s> <http://example.com/p> <http://example.com/o> <http://example.com/g> .\n".as_bytes()); /// assert_eq!(buffer.as_slice(), "<http://example.com/s> <http://example.com/p> <http://example.com/o> <http://example.com/g> .\n".as_bytes());
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[must_use]
pub struct RdfSerializer { pub struct RdfSerializer {
format: RdfFormat, format: RdfFormat,
} }

@ -50,6 +50,7 @@ use tokio::io::{AsyncRead, BufReader as AsyncBufReader};
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[derive(Default)] #[derive(Default)]
#[must_use]
pub struct RdfXmlParser { pub struct RdfXmlParser {
base: Option<Iri<String>>, base: Option<Iri<String>>,
} }
@ -188,6 +189,7 @@ impl RdfXmlParser {
/// assert_eq!(2, count); /// assert_eq!(2, count);
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[must_use]
pub struct FromReadRdfXmlReader<R: Read> { pub struct FromReadRdfXmlReader<R: Read> {
results: Vec<Triple>, results: Vec<Triple>,
reader: RdfXmlReader<BufReader<R>>, reader: RdfXmlReader<BufReader<R>>,
@ -259,6 +261,7 @@ impl<R: Read> FromReadRdfXmlReader<R> {
/// } /// }
/// ``` /// ```
#[cfg(feature = "async-tokio")] #[cfg(feature = "async-tokio")]
#[must_use]
pub struct FromTokioAsyncReadRdfXmlReader<R: AsyncRead + Unpin> { pub struct FromTokioAsyncReadRdfXmlReader<R: AsyncRead + Unpin> {
results: Vec<Triple>, results: Vec<Triple>,
reader: RdfXmlReader<AsyncBufReader<R>>, reader: RdfXmlReader<AsyncBufReader<R>>,

@ -27,6 +27,7 @@ use tokio::io::AsyncWrite;
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[derive(Default)] #[derive(Default)]
#[must_use]
pub struct RdfXmlSerializer; pub struct RdfXmlSerializer;
impl RdfXmlSerializer { impl RdfXmlSerializer {
@ -123,6 +124,7 @@ impl RdfXmlSerializer {
/// ); /// );
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[must_use]
pub struct ToWriteRdfXmlWriter<W: Write> { pub struct ToWriteRdfXmlWriter<W: Write> {
writer: Writer<W>, writer: Writer<W>,
inner: InnerRdfXmlWriter, inner: InnerRdfXmlWriter,
@ -176,6 +178,7 @@ impl<W: Write> ToWriteRdfXmlWriter<W> {
/// } /// }
/// ``` /// ```
#[cfg(feature = "async-tokio")] #[cfg(feature = "async-tokio")]
#[must_use]
pub struct ToTokioAsyncWriteRdfXmlWriter<W: AsyncWrite + Unpin> { pub struct ToTokioAsyncWriteRdfXmlWriter<W: AsyncWrite + Unpin> {
writer: Writer<W>, writer: Writer<W>,
inner: InnerRdfXmlWriter, inner: InnerRdfXmlWriter,

@ -204,6 +204,7 @@ impl From<Quad> for N3Quad {
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[derive(Default)] #[derive(Default)]
#[must_use]
pub struct N3Parser { pub struct N3Parser {
base: Option<Iri<String>>, base: Option<Iri<String>>,
prefixes: HashMap<String, Iri<String>>, prefixes: HashMap<String, Iri<String>>,
@ -376,6 +377,7 @@ impl N3Parser {
/// assert_eq!(2, count); /// assert_eq!(2, count);
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[must_use]
pub struct FromReadN3Reader<R: Read> { pub struct FromReadN3Reader<R: Read> {
inner: FromReadIterator<R, N3Recognizer>, inner: FromReadIterator<R, N3Recognizer>,
} }
@ -420,6 +422,7 @@ impl<R: Read> Iterator for FromReadN3Reader<R> {
/// } /// }
/// ``` /// ```
#[cfg(feature = "async-tokio")] #[cfg(feature = "async-tokio")]
#[must_use]
pub struct FromTokioAsyncReadN3Reader<R: AsyncRead + Unpin> { pub struct FromTokioAsyncReadN3Reader<R: AsyncRead + Unpin> {
inner: FromTokioAsyncReadIterator<R, N3Recognizer>, inner: FromTokioAsyncReadIterator<R, N3Recognizer>,
} }

@ -35,6 +35,7 @@ use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt};
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[derive(Default)] #[derive(Default)]
#[must_use]
pub struct NQuadsParser { pub struct NQuadsParser {
#[cfg(feature = "rdf-star")] #[cfg(feature = "rdf-star")]
with_quoted_triples: bool, with_quoted_triples: bool,
@ -50,7 +51,6 @@ impl NQuadsParser {
/// Enables [N-Quads-star](https://w3c.github.io/rdf-star/cg-spec/2021-12-17.html#n-quads-star). /// Enables [N-Quads-star](https://w3c.github.io/rdf-star/cg-spec/2021-12-17.html#n-quads-star).
#[cfg(feature = "rdf-star")] #[cfg(feature = "rdf-star")]
#[inline] #[inline]
#[must_use]
pub fn with_quoted_triples(mut self) -> Self { pub fn with_quoted_triples(mut self) -> Self {
self.with_quoted_triples = true; self.with_quoted_triples = true;
self self
@ -193,6 +193,7 @@ impl NQuadsParser {
/// assert_eq!(2, count); /// assert_eq!(2, count);
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[must_use]
pub struct FromReadNQuadsReader<R: Read> { pub struct FromReadNQuadsReader<R: Read> {
inner: FromReadIterator<R, NQuadsRecognizer>, inner: FromReadIterator<R, NQuadsRecognizer>,
} }
@ -233,6 +234,7 @@ impl<R: Read> Iterator for FromReadNQuadsReader<R> {
/// } /// }
/// ``` /// ```
#[cfg(feature = "async-tokio")] #[cfg(feature = "async-tokio")]
#[must_use]
pub struct FromTokioAsyncReadNQuadsReader<R: AsyncRead + Unpin> { pub struct FromTokioAsyncReadNQuadsReader<R: AsyncRead + Unpin> {
inner: FromTokioAsyncReadIterator<R, NQuadsRecognizer>, inner: FromTokioAsyncReadIterator<R, NQuadsRecognizer>,
} }
@ -334,6 +336,7 @@ impl LowLevelNQuadsReader {
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[derive(Default)] #[derive(Default)]
#[must_use]
pub struct NQuadsSerializer; pub struct NQuadsSerializer;
impl NQuadsSerializer { impl NQuadsSerializer {
@ -449,6 +452,7 @@ impl NQuadsSerializer {
/// ); /// );
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[must_use]
pub struct ToWriteNQuadsWriter<W: Write> { pub struct ToWriteNQuadsWriter<W: Write> {
write: W, write: W,
writer: LowLevelNQuadsWriter, writer: LowLevelNQuadsWriter,
@ -490,6 +494,7 @@ impl<W: Write> ToWriteNQuadsWriter<W> {
/// } /// }
/// ``` /// ```
#[cfg(feature = "async-tokio")] #[cfg(feature = "async-tokio")]
#[must_use]
pub struct ToTokioAsyncWriteNQuadsWriter<W: AsyncWrite + Unpin> { pub struct ToTokioAsyncWriteNQuadsWriter<W: AsyncWrite + Unpin> {
write: W, write: W,
writer: LowLevelNQuadsWriter, writer: LowLevelNQuadsWriter,

@ -36,6 +36,7 @@ use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt};
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[derive(Default)] #[derive(Default)]
#[must_use]
pub struct NTriplesParser { pub struct NTriplesParser {
#[cfg(feature = "rdf-star")] #[cfg(feature = "rdf-star")]
with_quoted_triples: bool, with_quoted_triples: bool,
@ -51,7 +52,6 @@ impl NTriplesParser {
/// Enables [N-Triples-star](https://w3c.github.io/rdf-star/cg-spec/2021-12-17.html#n-triples-star). /// Enables [N-Triples-star](https://w3c.github.io/rdf-star/cg-spec/2021-12-17.html#n-triples-star).
#[cfg(feature = "rdf-star")] #[cfg(feature = "rdf-star")]
#[inline] #[inline]
#[must_use]
pub fn with_quoted_triples(mut self) -> Self { pub fn with_quoted_triples(mut self) -> Self {
self.with_quoted_triples = true; self.with_quoted_triples = true;
self self
@ -194,6 +194,7 @@ impl NTriplesParser {
/// assert_eq!(2, count); /// assert_eq!(2, count);
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[must_use]
pub struct FromReadNTriplesReader<R: Read> { pub struct FromReadNTriplesReader<R: Read> {
inner: FromReadIterator<R, NQuadsRecognizer>, inner: FromReadIterator<R, NQuadsRecognizer>,
} }
@ -234,6 +235,7 @@ impl<R: Read> Iterator for FromReadNTriplesReader<R> {
/// } /// }
/// ``` /// ```
#[cfg(feature = "async-tokio")] #[cfg(feature = "async-tokio")]
#[must_use]
pub struct FromTokioAsyncReadNTriplesReader<R: AsyncRead + Unpin> { pub struct FromTokioAsyncReadNTriplesReader<R: AsyncRead + Unpin> {
inner: FromTokioAsyncReadIterator<R, NQuadsRecognizer>, inner: FromTokioAsyncReadIterator<R, NQuadsRecognizer>,
} }
@ -334,6 +336,7 @@ impl LowLevelNTriplesReader {
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[derive(Default)] #[derive(Default)]
#[must_use]
pub struct NTriplesSerializer; pub struct NTriplesSerializer;
impl NTriplesSerializer { impl NTriplesSerializer {
@ -445,6 +448,7 @@ impl NTriplesSerializer {
/// ); /// );
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[must_use]
pub struct ToWriteNTriplesWriter<W: Write> { pub struct ToWriteNTriplesWriter<W: Write> {
write: W, write: W,
writer: LowLevelNTriplesWriter, writer: LowLevelNTriplesWriter,
@ -485,6 +489,7 @@ impl<W: Write> ToWriteNTriplesWriter<W> {
/// } /// }
/// ``` /// ```
#[cfg(feature = "async-tokio")] #[cfg(feature = "async-tokio")]
#[must_use]
pub struct ToTokioAsyncWriteNTriplesWriter<W: AsyncWrite + Unpin> { pub struct ToTokioAsyncWriteNTriplesWriter<W: AsyncWrite + Unpin> {
write: W, write: W,
writer: LowLevelNTriplesWriter, writer: LowLevelNTriplesWriter,

@ -40,6 +40,7 @@ use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt};
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[derive(Default)] #[derive(Default)]
#[must_use]
pub struct TriGParser { pub struct TriGParser {
base: Option<Iri<String>>, base: Option<Iri<String>>,
prefixes: HashMap<String, Iri<String>>, prefixes: HashMap<String, Iri<String>>,
@ -74,7 +75,6 @@ impl TriGParser {
/// Enables [TriG-star](https://w3c.github.io/rdf-star/cg-spec/2021-12-17.html#trig-star). /// Enables [TriG-star](https://w3c.github.io/rdf-star/cg-spec/2021-12-17.html#trig-star).
#[cfg(feature = "rdf-star")] #[cfg(feature = "rdf-star")]
#[inline] #[inline]
#[must_use]
pub fn with_quoted_triples(mut self) -> Self { pub fn with_quoted_triples(mut self) -> Self {
self.with_quoted_triples = true; self.with_quoted_triples = true;
self self
@ -224,6 +224,7 @@ impl TriGParser {
/// assert_eq!(2, count); /// assert_eq!(2, count);
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[must_use]
pub struct FromReadTriGReader<R: Read> { pub struct FromReadTriGReader<R: Read> {
inner: FromReadIterator<R, TriGRecognizer>, inner: FromReadIterator<R, TriGRecognizer>,
} }
@ -266,6 +267,7 @@ impl<R: Read> Iterator for FromReadTriGReader<R> {
/// } /// }
/// ``` /// ```
#[cfg(feature = "async-tokio")] #[cfg(feature = "async-tokio")]
#[must_use]
pub struct FromTokioAsyncReadTriGReader<R: AsyncRead + Unpin> { pub struct FromTokioAsyncReadTriGReader<R: AsyncRead + Unpin> {
inner: FromTokioAsyncReadIterator<R, TriGRecognizer>, inner: FromTokioAsyncReadIterator<R, TriGRecognizer>,
} }
@ -367,6 +369,7 @@ impl LowLevelTriGReader {
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[derive(Default)] #[derive(Default)]
#[must_use]
pub struct TriGSerializer; pub struct TriGSerializer;
impl TriGSerializer { impl TriGSerializer {
@ -486,6 +489,7 @@ impl TriGSerializer {
/// ); /// );
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[must_use]
pub struct ToWriteTriGWriter<W: Write> { pub struct ToWriteTriGWriter<W: Write> {
write: W, write: W,
writer: LowLevelTriGWriter, writer: LowLevelTriGWriter,
@ -528,6 +532,7 @@ impl<W: Write> ToWriteTriGWriter<W> {
/// } /// }
/// ``` /// ```
#[cfg(feature = "async-tokio")] #[cfg(feature = "async-tokio")]
#[must_use]
pub struct ToTokioAsyncWriteTriGWriter<W: AsyncWrite + Unpin> { pub struct ToTokioAsyncWriteTriGWriter<W: AsyncWrite + Unpin> {
write: W, write: W,
writer: LowLevelTriGWriter, writer: LowLevelTriGWriter,

@ -42,6 +42,7 @@ use tokio::io::{AsyncRead, AsyncWrite};
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[derive(Default)] #[derive(Default)]
#[must_use]
pub struct TurtleParser { pub struct TurtleParser {
base: Option<Iri<String>>, base: Option<Iri<String>>,
prefixes: HashMap<String, Iri<String>>, prefixes: HashMap<String, Iri<String>>,
@ -76,7 +77,6 @@ impl TurtleParser {
/// Enables [Turtle-star](https://w3c.github.io/rdf-star/cg-spec/2021-12-17.html#turtle-star). /// Enables [Turtle-star](https://w3c.github.io/rdf-star/cg-spec/2021-12-17.html#turtle-star).
#[cfg(feature = "rdf-star")] #[cfg(feature = "rdf-star")]
#[inline] #[inline]
#[must_use]
pub fn with_quoted_triples(mut self) -> Self { pub fn with_quoted_triples(mut self) -> Self {
self.with_quoted_triples = true; self.with_quoted_triples = true;
self self
@ -226,6 +226,7 @@ impl TurtleParser {
/// assert_eq!(2, count); /// assert_eq!(2, count);
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[must_use]
pub struct FromReadTurtleReader<R: Read> { pub struct FromReadTurtleReader<R: Read> {
inner: FromReadIterator<R, TriGRecognizer>, inner: FromReadIterator<R, TriGRecognizer>,
} }
@ -268,6 +269,7 @@ impl<R: Read> Iterator for FromReadTurtleReader<R> {
/// } /// }
/// ``` /// ```
#[cfg(feature = "async-tokio")] #[cfg(feature = "async-tokio")]
#[must_use]
pub struct FromTokioAsyncReadTurtleReader<R: AsyncRead + Unpin> { pub struct FromTokioAsyncReadTurtleReader<R: AsyncRead + Unpin> {
inner: FromTokioAsyncReadIterator<R, TriGRecognizer>, inner: FromTokioAsyncReadIterator<R, TriGRecognizer>,
} }
@ -368,6 +370,7 @@ impl LowLevelTurtleReader {
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[derive(Default)] #[derive(Default)]
#[must_use]
pub struct TurtleSerializer { pub struct TurtleSerializer {
inner: TriGSerializer, inner: TriGSerializer,
} }
@ -480,6 +483,7 @@ impl TurtleSerializer {
/// ); /// );
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
#[must_use]
pub struct ToWriteTurtleWriter<W: Write> { pub struct ToWriteTurtleWriter<W: Write> {
inner: ToWriteTriGWriter<W>, inner: ToWriteTriGWriter<W>,
} }
@ -520,6 +524,7 @@ impl<W: Write> ToWriteTurtleWriter<W> {
/// } /// }
/// ``` /// ```
#[cfg(feature = "async-tokio")] #[cfg(feature = "async-tokio")]
#[must_use]
pub struct ToTokioAsyncWriteTurtleWriter<W: AsyncWrite + Unpin> { pub struct ToTokioAsyncWriteTurtleWriter<W: AsyncWrite + Unpin> {
inner: ToTokioAsyncWriteTriGWriter<W>, inner: ToTokioAsyncWriteTriGWriter<W>,
} }

Loading…
Cancel
Save