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
pull/46/head
Tpt 4 years ago
parent f38c5577cc
commit 3e11180405
  1. 4
      lib/src/sparql/json_results.rs
  2. 4
      lib/src/sparql/model.rs
  3. 2
      lib/src/sparql/xml_results.rs
  4. 8
      lib/src/store/memory.rs
  5. 4
      lib/src/store/mod.rs
  6. 8
      lib/src/store/rocksdb.rs
  7. 8
      lib/src/store/sled.rs

@ -6,7 +6,7 @@ use crate::Error;
use crate::Result; use crate::Result;
use std::io::Write; 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 { match results {
QueryResult::Boolean(value) => { QueryResult::Boolean(value) => {
sink.write_all(b"{\"head\":{},\"boolean\":")?; sink.write_all(b"{\"head\":{},\"boolean\":")?;
@ -81,7 +81,7 @@ pub fn write_json_results(results: QueryResult, mut sink: &mut impl Write) -> Re
Ok(()) 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"\"")?; sink.write_all(b"\"")?;
for c in s.chars() { for c in s.chars() {
match c { match c {

@ -51,7 +51,7 @@ impl QueryResult {
/// assert_eq!(results, "{\"head\":{\"vars\":[\"s\"]},\"results\":{\"bindings\":[{\"s\":{\"type\":\"uri\",\"value\":\"http://example.com\"}}]}}".as_bytes()); /// assert_eq!(results, "{\"head\":{\"vars\":[\"s\"]},\"results\":{\"bindings\":[{\"s\":{\"type\":\"uri\",\"value\":\"http://example.com\"}}]}}".as_bytes());
/// # oxigraph::Result::Ok(()) /// # 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 { match syntax {
QueryResultSyntax::Xml => write_xml_results(self, writer), QueryResultSyntax::Xml => write_xml_results(self, writer),
QueryResultSyntax::Json => write_json_results(self, writer), QueryResultSyntax::Json => write_json_results(self, writer),
@ -78,7 +78,7 @@ impl QueryResult {
/// assert_eq!(results, graph); /// assert_eq!(results, graph);
/// # oxigraph::Result::Ok(()) /// # 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 { if let QueryResult::Graph(triples) = self {
match syntax { match syntax {
GraphSyntax::NTriples => { GraphSyntax::NTriples => {

@ -17,7 +17,7 @@ use std::io::Write;
use std::iter::empty; use std::iter::empty;
use std::rc::Rc; 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); let mut writer = Writer::new(sink);
match results { match results {
QueryResult::Boolean(value) => { QueryResult::Boolean(value) => {

@ -359,7 +359,7 @@ impl MemoryStore {
/// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind. /// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
pub fn dump_graph( pub fn dump_graph(
&self, &self,
writer: &mut impl Write, writer: impl Write,
syntax: GraphSyntax, syntax: GraphSyntax,
from_graph_name: &GraphName, from_graph_name: &GraphName,
) -> Result<(), io::Error> { ) -> 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 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. /// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
pub fn dump_dataset( pub fn dump_dataset(&self, writer: impl Write, syntax: DatasetSyntax) -> Result<(), io::Error> {
&self,
writer: &mut impl Write,
syntax: DatasetSyntax,
) -> Result<(), io::Error> {
dump_dataset( dump_dataset(
self.quads_for_pattern(None, None, None, None).map(Ok), self.quads_for_pattern(None, None, None, None).map(Ok),
writer, writer,

@ -109,7 +109,7 @@ where
fn dump_graph( fn dump_graph(
triples: impl Iterator<Item = Result<Triple, io::Error>>, triples: impl Iterator<Item = Result<Triple, io::Error>>,
writer: &mut impl Write, writer: impl Write,
syntax: GraphSyntax, syntax: GraphSyntax,
) -> Result<(), io::Error> { ) -> Result<(), io::Error> {
match syntax { match syntax {
@ -179,7 +179,7 @@ where
fn dump_dataset( fn dump_dataset(
quads: impl Iterator<Item = Result<Quad, io::Error>>, quads: impl Iterator<Item = Result<Quad, io::Error>>,
writer: &mut impl Write, writer: impl Write,
syntax: DatasetSyntax, syntax: DatasetSyntax,
) -> Result<(), io::Error> { ) -> Result<(), io::Error> {
match syntax { match syntax {

@ -242,7 +242,7 @@ impl RocksDbStore {
/// See `MemoryStore` for a usage example. /// See `MemoryStore` for a usage example.
pub fn dump_graph( pub fn dump_graph(
&self, &self,
writer: &mut impl Write, writer: impl Write,
syntax: GraphSyntax, syntax: GraphSyntax,
from_graph_name: &GraphName, from_graph_name: &GraphName,
) -> Result<(), io::Error> { ) -> Result<(), io::Error> {
@ -257,11 +257,7 @@ impl RocksDbStore {
/// Dumps the store dataset into a file. /// Dumps the store dataset into a file.
/// ///
/// See `MemoryStore` for a usage example. /// See `MemoryStore` for a usage example.
pub fn dump_dataset( pub fn dump_dataset(&self, writer: impl Write, syntax: DatasetSyntax) -> Result<(), io::Error> {
&self,
writer: &mut impl Write,
syntax: DatasetSyntax,
) -> Result<(), io::Error> {
dump_dataset( dump_dataset(
self.quads_for_pattern(None, None, None, None), self.quads_for_pattern(None, None, None, None),
writer, writer,

@ -226,7 +226,7 @@ impl SledStore {
/// See `MemoryStore` for a usage example. /// See `MemoryStore` for a usage example.
pub fn dump_graph( pub fn dump_graph(
&self, &self,
writer: &mut impl Write, writer: impl Write,
syntax: GraphSyntax, syntax: GraphSyntax,
from_graph_name: &GraphName, from_graph_name: &GraphName,
) -> Result<(), io::Error> { ) -> Result<(), io::Error> {
@ -241,11 +241,7 @@ impl SledStore {
/// Dumps the store dataset into a file. /// Dumps the store dataset into a file.
/// ///
/// See `MemoryStore` for a usage example. /// See `MemoryStore` for a usage example.
pub fn dump_dataset( pub fn dump_dataset(&self, writer: impl Write, syntax: DatasetSyntax) -> Result<(), io::Error> {
&self,
writer: &mut impl Write,
syntax: DatasetSyntax,
) -> Result<(), io::Error> {
dump_dataset( dump_dataset(
self.quads_for_pattern(None, None, None, None), self.quads_for_pattern(None, None, None, None),
writer, writer,

Loading…
Cancel
Save