Skip to content

Commit

Permalink
refactor(cognitarium): return writer from finish function
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamel committed Jun 17, 2023
1 parent 23959b5 commit 74fa932
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions contracts/okp4-cognitarium/src/rdf/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<R: BufRead> TripleReader<R> {
}

impl<W: std::io::Write> TripleWriter<W> {
pub fn new(format: DataFormat, dst: W) -> Self {
pub fn new(format: &DataFormat, dst: W) -> Self {
TripleWriter {
writer: match format {
DataFormat::RDFXml => TriplesWriterKind::RdfXml(RdfXmlFormatter::new(dst)),
Expand Down Expand Up @@ -110,7 +110,7 @@ impl<W: std::io::Write> TripleWriter<W> {
Ok(())
}

pub fn finish(self) -> io::Result<()> {
pub fn finish(self) -> io::Result<W> {
match self.writer {
TriplesWriterKind::Turtle(formatter) => formatter.finish(),
TriplesWriterKind::NTriples(formatter) => formatter.finish(),
Expand All @@ -120,7 +120,6 @@ impl<W: std::io::Write> TripleWriter<W> {
Err(e) => Err(io::Error::new(io::ErrorKind::Other, e.to_string())),
},
}
.map(|_| ())
}
}

Expand Down

0 comments on commit 74fa932

Please sign in to comment.