From 3e111804058cd217d43eeb68e879759f93bdd8f6 Mon Sep 17 00:00:00 2001 From: Tpt Date: Wed, 29 Jul 2020 23:05:19 +0200 Subject: [PATCH] Converts all "&mut impl Write" into "impl Write" Write is implemented for all &mut impl Write so it makes the API a bit easier to use --- lib/src/sparql/json_results.rs | 4 ++-- lib/src/sparql/model.rs | 4 ++-- lib/src/sparql/xml_results.rs | 2 +- lib/src/store/memory.rs | 8 ++------ lib/src/store/mod.rs | 4 ++-- lib/src/store/rocksdb.rs | 8 ++------ lib/src/store/sled.rs | 8 ++------ 7 files changed, 13 insertions(+), 25 deletions(-) diff --git a/lib/src/sparql/json_results.rs b/lib/src/sparql/json_results.rs index d95070c5..231041d1 100644 --- a/lib/src/sparql/json_results.rs +++ b/lib/src/sparql/json_results.rs @@ -6,7 +6,7 @@ use crate::Error; use crate::Result; use std::io::Write; -pub fn write_json_results(results: QueryResult, mut sink: &mut impl Write) -> Result<()> { +pub fn write_json_results(results: QueryResult, mut sink: impl Write) -> Result<()> { match results { QueryResult::Boolean(value) => { sink.write_all(b"{\"head\":{},\"boolean\":")?; @@ -81,7 +81,7 @@ pub fn write_json_results(results: QueryResult, mut sink: &mut impl Write) -> Re Ok(()) } -fn write_escaped_json_string(s: &str, sink: &mut impl Write) -> Result<()> { +fn write_escaped_json_string(s: &str, mut sink: impl Write) -> Result<()> { sink.write_all(b"\"")?; for c in s.chars() { match c { diff --git a/lib/src/sparql/model.rs b/lib/src/sparql/model.rs index efb35324..df4f2d00 100644 --- a/lib/src/sparql/model.rs +++ b/lib/src/sparql/model.rs @@ -51,7 +51,7 @@ impl QueryResult { /// assert_eq!(results, "{\"head\":{\"vars\":[\"s\"]},\"results\":{\"bindings\":[{\"s\":{\"type\":\"uri\",\"value\":\"http://example.com\"}}]}}".as_bytes()); /// # oxigraph::Result::Ok(()) /// ``` - pub fn write(self, writer: &mut impl Write, syntax: QueryResultSyntax) -> Result<()> { + pub fn write(self, writer: impl Write, syntax: QueryResultSyntax) -> Result<()> { match syntax { QueryResultSyntax::Xml => write_xml_results(self, writer), QueryResultSyntax::Json => write_json_results(self, writer), @@ -78,7 +78,7 @@ impl QueryResult { /// assert_eq!(results, graph); /// # oxigraph::Result::Ok(()) /// ``` - pub fn write_graph(self, write: &mut impl Write, syntax: GraphSyntax) -> Result<()> { + pub fn write_graph(self, write: impl Write, syntax: GraphSyntax) -> Result<()> { if let QueryResult::Graph(triples) = self { match syntax { GraphSyntax::NTriples => { diff --git a/lib/src/sparql/xml_results.rs b/lib/src/sparql/xml_results.rs index 75c3b533..aee096f7 100644 --- a/lib/src/sparql/xml_results.rs +++ b/lib/src/sparql/xml_results.rs @@ -17,7 +17,7 @@ use std::io::Write; use std::iter::empty; use std::rc::Rc; -pub fn write_xml_results(results: QueryResult, sink: &mut impl Write) -> Result<()> { +pub fn write_xml_results(results: QueryResult, sink: impl Write) -> Result<()> { let mut writer = Writer::new(sink); match results { QueryResult::Boolean(value) => { diff --git a/lib/src/store/memory.rs b/lib/src/store/memory.rs index 6f671253..18ab8e42 100644 --- a/lib/src/store/memory.rs +++ b/lib/src/store/memory.rs @@ -359,7 +359,7 @@ impl MemoryStore { /// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind. pub fn dump_graph( &self, - writer: &mut impl Write, + writer: impl Write, syntax: GraphSyntax, from_graph_name: &GraphName, ) -> Result<(), io::Error> { @@ -390,11 +390,7 @@ impl MemoryStore { /// /// Errors related to parameter validation like the base IRI use the `INVALID_INPUT` error kind. /// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind. - pub fn dump_dataset( - &self, - writer: &mut impl Write, - syntax: DatasetSyntax, - ) -> Result<(), io::Error> { + pub fn dump_dataset(&self, writer: impl Write, syntax: DatasetSyntax) -> Result<(), io::Error> { dump_dataset( self.quads_for_pattern(None, None, None, None).map(Ok), writer, diff --git a/lib/src/store/mod.rs b/lib/src/store/mod.rs index c1625217..949595e7 100644 --- a/lib/src/store/mod.rs +++ b/lib/src/store/mod.rs @@ -109,7 +109,7 @@ where fn dump_graph( triples: impl Iterator>, - writer: &mut impl Write, + writer: impl Write, syntax: GraphSyntax, ) -> Result<(), io::Error> { match syntax { @@ -179,7 +179,7 @@ where fn dump_dataset( quads: impl Iterator>, - writer: &mut impl Write, + writer: impl Write, syntax: DatasetSyntax, ) -> Result<(), io::Error> { match syntax { diff --git a/lib/src/store/rocksdb.rs b/lib/src/store/rocksdb.rs index 2b09541b..c4206ff7 100644 --- a/lib/src/store/rocksdb.rs +++ b/lib/src/store/rocksdb.rs @@ -242,7 +242,7 @@ impl RocksDbStore { /// See `MemoryStore` for a usage example. pub fn dump_graph( &self, - writer: &mut impl Write, + writer: impl Write, syntax: GraphSyntax, from_graph_name: &GraphName, ) -> Result<(), io::Error> { @@ -257,11 +257,7 @@ impl RocksDbStore { /// Dumps the store dataset into a file. /// /// See `MemoryStore` for a usage example. - pub fn dump_dataset( - &self, - writer: &mut impl Write, - syntax: DatasetSyntax, - ) -> Result<(), io::Error> { + pub fn dump_dataset(&self, writer: impl Write, syntax: DatasetSyntax) -> Result<(), io::Error> { dump_dataset( self.quads_for_pattern(None, None, None, None), writer, diff --git a/lib/src/store/sled.rs b/lib/src/store/sled.rs index 8884538b..f560a489 100644 --- a/lib/src/store/sled.rs +++ b/lib/src/store/sled.rs @@ -226,7 +226,7 @@ impl SledStore { /// See `MemoryStore` for a usage example. pub fn dump_graph( &self, - writer: &mut impl Write, + writer: impl Write, syntax: GraphSyntax, from_graph_name: &GraphName, ) -> Result<(), io::Error> { @@ -241,11 +241,7 @@ impl SledStore { /// Dumps the store dataset into a file. /// /// See `MemoryStore` for a usage example. - pub fn dump_dataset( - &self, - writer: &mut impl Write, - syntax: DatasetSyntax, - ) -> Result<(), io::Error> { + pub fn dump_dataset(&self, writer: impl Write, syntax: DatasetSyntax) -> Result<(), io::Error> { dump_dataset( self.quads_for_pattern(None, None, None, None), writer,