From d44f9bee7a43179584a9591c6d4fd00e68ddcb0e Mon Sep 17 00:00:00 2001 From: Tpt Date: Sun, 20 Aug 2023 19:29:50 +0200 Subject: [PATCH] I/O adds extra #[must_use] annotations --- lib/oxrdfio/src/parser.rs | 5 +---- lib/oxrdfio/src/serializer.rs | 1 + lib/oxrdfxml/src/parser.rs | 3 +++ lib/oxrdfxml/src/serializer.rs | 3 +++ lib/oxttl/src/n3.rs | 3 +++ lib/oxttl/src/nquads.rs | 7 ++++++- lib/oxttl/src/ntriples.rs | 7 ++++++- lib/oxttl/src/trig.rs | 7 ++++++- lib/oxttl/src/turtle.rs | 7 ++++++- 9 files changed, 35 insertions(+), 8 deletions(-) diff --git a/lib/oxrdfio/src/parser.rs b/lib/oxrdfio/src/parser.rs index 4c7090b6..25f86598 100644 --- a/lib/oxrdfio/src/parser.rs +++ b/lib/oxrdfio/src/parser.rs @@ -53,6 +53,7 @@ use tokio::io::AsyncRead; /// assert_eq!(quads[0].subject.to_string(), ""); /// # std::io::Result::Ok(()) /// ``` +#[must_use] pub struct RdfParser { inner: RdfParserKind, default_graph: GraphName, @@ -72,7 +73,6 @@ enum RdfParserKind { impl RdfParser { /// Builds a parser for the given format. #[inline] - #[must_use] pub fn from_format(format: RdfFormat) -> Self { Self { inner: match format { @@ -172,7 +172,6 @@ impl RdfParser { /// # Result::<_,Box>::Ok(()) /// ``` #[inline] - #[must_use] pub fn with_default_graph(self, default_graph: impl Into) -> Self { Self { inner: self.inner, @@ -195,7 +194,6 @@ impl RdfParser { /// assert!(parser.parse_read(file.as_bytes()).next().unwrap().is_err()); /// ``` #[inline] - #[must_use] pub fn without_named_graphs(self) -> Self { Self { inner: self.inner, @@ -224,7 +222,6 @@ impl RdfParser { /// # Result::<_,Box>::Ok(()) /// ``` #[inline] - #[must_use] pub fn rename_blank_nodes(self) -> Self { Self { inner: self.inner, diff --git a/lib/oxrdfio/src/serializer.rs b/lib/oxrdfio/src/serializer.rs index 26229e5d..6289ed28 100644 --- a/lib/oxrdfio/src/serializer.rs +++ b/lib/oxrdfio/src/serializer.rs @@ -48,6 +48,7 @@ use tokio::io::AsyncWrite; /// assert_eq!(buffer.as_slice(), " .\n".as_bytes()); /// # Result::<_,Box>::Ok(()) /// ``` +#[must_use] pub struct RdfSerializer { format: RdfFormat, } diff --git a/lib/oxrdfxml/src/parser.rs b/lib/oxrdfxml/src/parser.rs index a17f9ca4..747b2419 100644 --- a/lib/oxrdfxml/src/parser.rs +++ b/lib/oxrdfxml/src/parser.rs @@ -50,6 +50,7 @@ use tokio::io::{AsyncRead, BufReader as AsyncBufReader}; /// # Result::<_,Box>::Ok(()) /// ``` #[derive(Default)] +#[must_use] pub struct RdfXmlParser { base: Option>, } @@ -188,6 +189,7 @@ impl RdfXmlParser { /// assert_eq!(2, count); /// # Result::<_,Box>::Ok(()) /// ``` +#[must_use] pub struct FromReadRdfXmlReader { results: Vec, reader: RdfXmlReader>, @@ -259,6 +261,7 @@ impl FromReadRdfXmlReader { /// } /// ``` #[cfg(feature = "async-tokio")] +#[must_use] pub struct FromTokioAsyncReadRdfXmlReader { results: Vec, reader: RdfXmlReader>, diff --git a/lib/oxrdfxml/src/serializer.rs b/lib/oxrdfxml/src/serializer.rs index e3d93065..d3e9949f 100644 --- a/lib/oxrdfxml/src/serializer.rs +++ b/lib/oxrdfxml/src/serializer.rs @@ -27,6 +27,7 @@ use tokio::io::AsyncWrite; /// # Result::<_,Box>::Ok(()) /// ``` #[derive(Default)] +#[must_use] pub struct RdfXmlSerializer; impl RdfXmlSerializer { @@ -123,6 +124,7 @@ impl RdfXmlSerializer { /// ); /// # Result::<_,Box>::Ok(()) /// ``` +#[must_use] pub struct ToWriteRdfXmlWriter { writer: Writer, inner: InnerRdfXmlWriter, @@ -176,6 +178,7 @@ impl ToWriteRdfXmlWriter { /// } /// ``` #[cfg(feature = "async-tokio")] +#[must_use] pub struct ToTokioAsyncWriteRdfXmlWriter { writer: Writer, inner: InnerRdfXmlWriter, diff --git a/lib/oxttl/src/n3.rs b/lib/oxttl/src/n3.rs index 0edb9d13..14c58413 100644 --- a/lib/oxttl/src/n3.rs +++ b/lib/oxttl/src/n3.rs @@ -204,6 +204,7 @@ impl From for N3Quad { /// # Result::<_,Box>::Ok(()) /// ``` #[derive(Default)] +#[must_use] pub struct N3Parser { base: Option>, prefixes: HashMap>, @@ -376,6 +377,7 @@ impl N3Parser { /// assert_eq!(2, count); /// # Result::<_,Box>::Ok(()) /// ``` +#[must_use] pub struct FromReadN3Reader { inner: FromReadIterator, } @@ -420,6 +422,7 @@ impl Iterator for FromReadN3Reader { /// } /// ``` #[cfg(feature = "async-tokio")] +#[must_use] pub struct FromTokioAsyncReadN3Reader { inner: FromTokioAsyncReadIterator, } diff --git a/lib/oxttl/src/nquads.rs b/lib/oxttl/src/nquads.rs index 71ac2d4c..caa7c642 100644 --- a/lib/oxttl/src/nquads.rs +++ b/lib/oxttl/src/nquads.rs @@ -35,6 +35,7 @@ use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt}; /// # Result::<_,Box>::Ok(()) /// ``` #[derive(Default)] +#[must_use] pub struct NQuadsParser { #[cfg(feature = "rdf-star")] 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). #[cfg(feature = "rdf-star")] #[inline] - #[must_use] pub fn with_quoted_triples(mut self) -> Self { self.with_quoted_triples = true; self @@ -193,6 +193,7 @@ impl NQuadsParser { /// assert_eq!(2, count); /// # Result::<_,Box>::Ok(()) /// ``` +#[must_use] pub struct FromReadNQuadsReader { inner: FromReadIterator, } @@ -233,6 +234,7 @@ impl Iterator for FromReadNQuadsReader { /// } /// ``` #[cfg(feature = "async-tokio")] +#[must_use] pub struct FromTokioAsyncReadNQuadsReader { inner: FromTokioAsyncReadIterator, } @@ -334,6 +336,7 @@ impl LowLevelNQuadsReader { /// # Result::<_,Box>::Ok(()) /// ``` #[derive(Default)] +#[must_use] pub struct NQuadsSerializer; impl NQuadsSerializer { @@ -449,6 +452,7 @@ impl NQuadsSerializer { /// ); /// # Result::<_,Box>::Ok(()) /// ``` +#[must_use] pub struct ToWriteNQuadsWriter { write: W, writer: LowLevelNQuadsWriter, @@ -490,6 +494,7 @@ impl ToWriteNQuadsWriter { /// } /// ``` #[cfg(feature = "async-tokio")] +#[must_use] pub struct ToTokioAsyncWriteNQuadsWriter { write: W, writer: LowLevelNQuadsWriter, diff --git a/lib/oxttl/src/ntriples.rs b/lib/oxttl/src/ntriples.rs index 07672f1a..f8c32b12 100644 --- a/lib/oxttl/src/ntriples.rs +++ b/lib/oxttl/src/ntriples.rs @@ -36,6 +36,7 @@ use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt}; /// # Result::<_,Box>::Ok(()) /// ``` #[derive(Default)] +#[must_use] pub struct NTriplesParser { #[cfg(feature = "rdf-star")] 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). #[cfg(feature = "rdf-star")] #[inline] - #[must_use] pub fn with_quoted_triples(mut self) -> Self { self.with_quoted_triples = true; self @@ -194,6 +194,7 @@ impl NTriplesParser { /// assert_eq!(2, count); /// # Result::<_,Box>::Ok(()) /// ``` +#[must_use] pub struct FromReadNTriplesReader { inner: FromReadIterator, } @@ -234,6 +235,7 @@ impl Iterator for FromReadNTriplesReader { /// } /// ``` #[cfg(feature = "async-tokio")] +#[must_use] pub struct FromTokioAsyncReadNTriplesReader { inner: FromTokioAsyncReadIterator, } @@ -334,6 +336,7 @@ impl LowLevelNTriplesReader { /// # Result::<_,Box>::Ok(()) /// ``` #[derive(Default)] +#[must_use] pub struct NTriplesSerializer; impl NTriplesSerializer { @@ -445,6 +448,7 @@ impl NTriplesSerializer { /// ); /// # Result::<_,Box>::Ok(()) /// ``` +#[must_use] pub struct ToWriteNTriplesWriter { write: W, writer: LowLevelNTriplesWriter, @@ -485,6 +489,7 @@ impl ToWriteNTriplesWriter { /// } /// ``` #[cfg(feature = "async-tokio")] +#[must_use] pub struct ToTokioAsyncWriteNTriplesWriter { write: W, writer: LowLevelNTriplesWriter, diff --git a/lib/oxttl/src/trig.rs b/lib/oxttl/src/trig.rs index f2c24ca0..6dfb2b43 100644 --- a/lib/oxttl/src/trig.rs +++ b/lib/oxttl/src/trig.rs @@ -40,6 +40,7 @@ use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt}; /// # Result::<_,Box>::Ok(()) /// ``` #[derive(Default)] +#[must_use] pub struct TriGParser { base: Option>, prefixes: HashMap>, @@ -74,7 +75,6 @@ impl TriGParser { /// Enables [TriG-star](https://w3c.github.io/rdf-star/cg-spec/2021-12-17.html#trig-star). #[cfg(feature = "rdf-star")] #[inline] - #[must_use] pub fn with_quoted_triples(mut self) -> Self { self.with_quoted_triples = true; self @@ -224,6 +224,7 @@ impl TriGParser { /// assert_eq!(2, count); /// # Result::<_,Box>::Ok(()) /// ``` +#[must_use] pub struct FromReadTriGReader { inner: FromReadIterator, } @@ -266,6 +267,7 @@ impl Iterator for FromReadTriGReader { /// } /// ``` #[cfg(feature = "async-tokio")] +#[must_use] pub struct FromTokioAsyncReadTriGReader { inner: FromTokioAsyncReadIterator, } @@ -367,6 +369,7 @@ impl LowLevelTriGReader { /// # Result::<_,Box>::Ok(()) /// ``` #[derive(Default)] +#[must_use] pub struct TriGSerializer; impl TriGSerializer { @@ -486,6 +489,7 @@ impl TriGSerializer { /// ); /// # Result::<_,Box>::Ok(()) /// ``` +#[must_use] pub struct ToWriteTriGWriter { write: W, writer: LowLevelTriGWriter, @@ -528,6 +532,7 @@ impl ToWriteTriGWriter { /// } /// ``` #[cfg(feature = "async-tokio")] +#[must_use] pub struct ToTokioAsyncWriteTriGWriter { write: W, writer: LowLevelTriGWriter, diff --git a/lib/oxttl/src/turtle.rs b/lib/oxttl/src/turtle.rs index 70be2806..133c9cca 100644 --- a/lib/oxttl/src/turtle.rs +++ b/lib/oxttl/src/turtle.rs @@ -42,6 +42,7 @@ use tokio::io::{AsyncRead, AsyncWrite}; /// # Result::<_,Box>::Ok(()) /// ``` #[derive(Default)] +#[must_use] pub struct TurtleParser { base: Option>, prefixes: HashMap>, @@ -76,7 +77,6 @@ impl TurtleParser { /// Enables [Turtle-star](https://w3c.github.io/rdf-star/cg-spec/2021-12-17.html#turtle-star). #[cfg(feature = "rdf-star")] #[inline] - #[must_use] pub fn with_quoted_triples(mut self) -> Self { self.with_quoted_triples = true; self @@ -226,6 +226,7 @@ impl TurtleParser { /// assert_eq!(2, count); /// # Result::<_,Box>::Ok(()) /// ``` +#[must_use] pub struct FromReadTurtleReader { inner: FromReadIterator, } @@ -268,6 +269,7 @@ impl Iterator for FromReadTurtleReader { /// } /// ``` #[cfg(feature = "async-tokio")] +#[must_use] pub struct FromTokioAsyncReadTurtleReader { inner: FromTokioAsyncReadIterator, } @@ -368,6 +370,7 @@ impl LowLevelTurtleReader { /// # Result::<_,Box>::Ok(()) /// ``` #[derive(Default)] +#[must_use] pub struct TurtleSerializer { inner: TriGSerializer, } @@ -480,6 +483,7 @@ impl TurtleSerializer { /// ); /// # Result::<_,Box>::Ok(()) /// ``` +#[must_use] pub struct ToWriteTurtleWriter { inner: ToWriteTriGWriter, } @@ -520,6 +524,7 @@ impl ToWriteTurtleWriter { /// } /// ``` #[cfg(feature = "async-tokio")] +#[must_use] pub struct ToTokioAsyncWriteTurtleWriter { inner: ToTokioAsyncWriteTriGWriter, }