Skip to content

Commit

Permalink
Fix unused function
Browse files Browse the repository at this point in the history
  • Loading branch information
DelSkayn committed Aug 15, 2024
1 parent 1900b53 commit f39831b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/implementations/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use std::path::PathBuf;

use super::super::Error;
use super::super::Revisioned;
use super::string::serialize_str;
use super::vecs::serialize_slice;

impl Revisioned for PathBuf {
#[inline]
fn serialize_revisioned<W: std::io::Write>(&self, writer: &mut W) -> Result<(), Error> {
match self.to_str() {
Some(s) => serialize_str(writer, s),
Some(s) => serialize_slice(s.as_bytes(), writer),
None => Err(Error::InvalidPath),
}
}
Expand Down
14 changes: 4 additions & 10 deletions src/implementations/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use core::str;

use crate::{Error, Revisioned};

pub(crate) fn serialize_str<W: std::io::Write>(writer: &mut W, str: &str) -> Result<(), Error> {
(str.len() as u64).serialize_revisioned(writer)?;
writer.write_all(str.as_bytes()).map_err(Error::Io)
}
use super::vecs::serialize_slice;

impl Revisioned for String {
fn revision() -> u16 {
Expand All @@ -14,16 +11,13 @@ impl Revisioned for String {

#[inline]
fn serialize_revisioned<W: std::io::Write>(&self, writer: &mut W) -> Result<(), Error> {
serialize_str(writer, self)
serialize_slice(self.as_bytes(), writer)
}

#[inline]
fn deserialize_revisioned<R: std::io::Read>(reader: &mut R) -> Result<Self, Error> {
let len: usize =
u64::deserialize_revisioned(reader)?.try_into().map_err(|_| Error::IntegerOverflow)?;
let mut slice = vec![0u8; len];
reader.read_exact(&mut slice).map_err(Error::Io)?;
String::from_utf8(slice).map_err(|x| Error::Utf8Error(x.utf8_error()))
let bytes = Vec::<u8>::deserialize_revisioned(reader)?;
String::from_utf8(bytes).map_err(|x| Error::Utf8Error(x.utf8_error()))
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/implementations/vecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ where
{
#[inline]
fn serialize_revisioned<W: std::io::Write>(&self, writer: &mut W) -> Result<(), Error> {
self.len().serialize_revisioned(writer)?;
for v in self {
v.serialize_revisioned(writer)?;
}
Ok(())
serialize_slice(self.as_slice(), writer)
}

#[inline]
Expand Down

0 comments on commit f39831b

Please sign in to comment.