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 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 {

@ -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 => {

@ -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) => {

@ -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,

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

@ -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,

@ -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,

Loading…
Cancel
Save