Work on passing tidy

This commit is contained in:
pjht 2024-06-12 11:31:46 -05:00
parent 0f099f3223
commit 6674184ac0
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E
12 changed files with 20 additions and 31 deletions

View File

@ -131,7 +131,7 @@ fn read_data_i8(&mut self) -> Result<i8, ValueReadError<Self::Error>> {
* so that rmpv and rmp-serde continue to compile without issue. * so that rmpv and rmp-serde continue to compile without issue.
* *
* *
* TODO: Remove this hack once we release a new version of rmp proper * FIXME: Remove this hack once we release a new version of rmp proper
*/ */
macro_rules! wrap_data_funcs_for_compatibility { macro_rules! wrap_data_funcs_for_compatibility {
@ -200,7 +200,7 @@ fn source(&self) -> Option<&(dyn error::Error + 'static)> {
impl Display for ValueReadError { impl Display for ValueReadError {
#[cold] #[cold]
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
// TODO: This should probably use formatting // FIXME: This should probably use formatting
f.write_str(match *self { f.write_str(match *self {
ValueReadError::InvalidMarkerRead(..) => "failed to read MessagePack marker", ValueReadError::InvalidMarkerRead(..) => "failed to read MessagePack marker",
ValueReadError::InvalidDataRead(..) => "failed to read MessagePack data", ValueReadError::InvalidDataRead(..) => "failed to read MessagePack data",
@ -398,7 +398,7 @@ pub fn read_int<T: FromPrimitive, R: RmpRead>(
/// ///
/// This function will silently retry on every EINTR received from the underlying `Read` until /// This function will silently retry on every EINTR received from the underlying `Read` until
/// successful read. /// successful read.
// TODO: Docs. // FIXME: Docs.
// NOTE: EINTR is managed internally. // NOTE: EINTR is managed internally.
pub fn read_array_len<R>(rd: &mut R) -> Result<u32, ValueReadError<R::Error>> pub fn read_array_len<R>(rd: &mut R) -> Result<u32, ValueReadError<R::Error>>
where where
@ -422,7 +422,7 @@ pub fn read_array_len<R>(rd: &mut R) -> Result<u32, ValueReadError<R::Error>>
/// ///
/// This function will silently retry on every EINTR received from the underlying `Read` until /// This function will silently retry on every EINTR received from the underlying `Read` until
/// successful read. /// successful read.
// TODO: Docs. // FIXME: Docs.
pub fn read_map_len<R: RmpRead>(rd: &mut R) -> Result<u32, ValueReadError<R::Error>> { pub fn read_map_len<R: RmpRead>(rd: &mut R) -> Result<u32, ValueReadError<R::Error>> {
let marker = read_marker(rd)?; let marker = read_marker(rd)?;
marker_to_len(rd, marker) marker_to_len(rd, marker)
@ -446,7 +446,7 @@ pub fn marker_to_len<R: RmpRead>(
/// ///
/// This function will silently retry on every EINTR received from the underlying `Read` until /// This function will silently retry on every EINTR received from the underlying `Read` until
/// successful read. /// successful read.
// TODO: Docs. // FIXME: Docs.
pub fn read_bin_len<R: RmpRead>(rd: &mut R) -> Result<u32, ValueReadError<R::Error>> { pub fn read_bin_len<R: RmpRead>(rd: &mut R) -> Result<u32, ValueReadError<R::Error>> {
match read_marker(rd)? { match read_marker(rd)? {
Marker::Bin8 => Ok(u32::from(rd.read_data_u8()?)), Marker::Bin8 => Ok(u32::from(rd.read_data_u8()?)),

View File

@ -106,7 +106,7 @@ fn read_str_len_with_nread<R>(rd: &mut R) -> Result<(u32, usize), ValueReadError
/// # Unstable /// # Unstable
/// ///
/// This function is **unstable**, because it needs review. /// This function is **unstable**, because it needs review.
// TODO: Stabilize. Mark error values for each error case (in docs). // FIXME: Stabilize. Mark error values for each error case (in docs).
pub fn read_str<'r, R>( pub fn read_str<'r, R>(
rd: &mut R, rd: &mut R,
buf: &'r mut [u8], buf: &'r mut [u8],
@ -146,7 +146,7 @@ pub fn read_str_data<'r, R>(
/// Attempts to read and decode a string value from the reader, returning a borrowed slice from it. /// Attempts to read and decode a string value from the reader, returning a borrowed slice from it.
/// ///
// TODO: Also it's possible to implement all borrowing functions for all `BufRead` implementors. // FIXME: Also it's possible to implement all borrowing functions for all `BufRead` implementors.
pub fn read_str_ref( pub fn read_str_ref(
rd: &[u8], rd: &[u8],
) -> Result<&[u8], DecodeStringError<'_, super::bytes::BytesReadError>> { ) -> Result<&[u8], DecodeStringError<'_, super::bytes::BytesReadError>> {

View File

@ -40,7 +40,7 @@ pub fn write_bin_len<W: RmpWrite>(
/// ///
/// This function will return `ValueWriteError` on any I/O error occurred while writing either the /// This function will return `ValueWriteError` on any I/O error occurred while writing either the
/// marker or the data. /// marker or the data.
// TODO: Docs, range check, example, visibility. // FIXME: Docs, range check, example, visibility.
pub fn write_bin<W: RmpWrite>(wr: &mut W, data: &[u8]) -> Result<(), ValueWriteError<W::Error>> { pub fn write_bin<W: RmpWrite>(wr: &mut W, data: &[u8]) -> Result<(), ValueWriteError<W::Error>> {
write_bin_len(wr, data.len() as u32)?; write_bin_len(wr, data.len() as u32)?;
wr.write_bytes(data).map_err(ValueWriteError::InvalidDataWrite) wr.write_bytes(data).map_err(ValueWriteError::InvalidDataWrite)

View File

@ -2,12 +2,12 @@
mod bin; mod bin;
mod dec; mod dec;
mod ext; // mod ext;
mod map; // mod map;
mod sint; mod sint;
mod str; mod str;
mod uint; mod uint;
mod vec; // mod vec;
pub use self::bin::{write_bin, write_bin_len}; pub use self::bin::{write_bin, write_bin_len};
pub use self::dec::{write_f32, write_f64}; pub use self::dec::{write_f32, write_f64};
@ -185,7 +185,7 @@ fn write_bytes(&mut self, buf: &[u8]) -> Result<(), Self::Error> {
/// An error that can occur when attempting to write multi-byte MessagePack value. /// An error that can occur when attempting to write multi-byte MessagePack value.
#[derive(Debug)] #[derive(Debug)]
#[allow(deprecated)] // TODO: Needed for compatibility #[allow(deprecated)] // FIXME: Needed for compatibility
pub enum ValueWriteError<E: RmpWriteErr = Error> { pub enum ValueWriteError<E: RmpWriteErr = Error> {
/// I/O error while writing marker. /// I/O error while writing marker.
InvalidMarkerWrite(E), InvalidMarkerWrite(E),

View File

@ -43,7 +43,7 @@ pub fn write_str_len<W: RmpWrite>(
/// ///
/// This function will return `ValueWriteError` on any I/O error occurred while writing either the /// This function will return `ValueWriteError` on any I/O error occurred while writing either the
/// marker or the data. /// marker or the data.
// TODO: Docs, range check, example, visibility. // FIXME: Docs, range check, example, visibility.
pub fn write_str<W: RmpWrite>(wr: &mut W, data: &str) -> Result<(), ValueWriteError<W::Error>> { pub fn write_str<W: RmpWrite>(wr: &mut W, data: &str) -> Result<(), ValueWriteError<W::Error>> {
write_str_len(wr, data.len() as u32)?; write_str_len(wr, data.len() as u32)?;
wr.write_bytes(data.as_bytes()).map_err(ValueWriteError::InvalidDataWrite) wr.write_bytes(data.as_bytes()).map_err(ValueWriteError::InvalidDataWrite)

View File

@ -695,7 +695,7 @@ fn deserialize_enum<V>(
} }
n => Err(Error::LengthMismatch(n)), n => Err(Error::LengthMismatch(n)),
}, },
// TODO: Check this is a string // FIXME: Check this is a string
Err(_) => visitor.visit_enum(UnitVariantAccess::new(self)), Err(_) => visitor.visit_enum(UnitVariantAccess::new(self)),
} }
} }
@ -1200,17 +1200,6 @@ fn read_slice<'a>(&'a mut self, len: usize) -> Result<Reference<'de, 'a, [u8]>,
} }
} }
#[test]
fn test_as_ref_reader() {
let buf = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let mut rd = ReadRefReader::new(&buf);
assert_eq!(rd.read_slice(1).unwrap(), Reference::Borrowed(&[0][..]));
assert_eq!(rd.read_slice(6).unwrap(), Reference::Borrowed(&[1, 2, 3, 4, 5, 6][..]));
assert!(rd.read_slice(5).is_err());
assert_eq!(rd.read_slice(4).unwrap(), Reference::Borrowed(&[7, 8, 9, 10][..]));
}
/// Deserialize an instance of type `T` from an I/O stream of MessagePack. /// Deserialize an instance of type `T` from an I/O stream of MessagePack.
/// ///
/// # Errors /// # Errors

View File

@ -30,7 +30,7 @@
pub enum Error { pub enum Error {
/// Failed to write a MessagePack value. /// Failed to write a MessagePack value.
InvalidValueWrite(ValueWriteError), InvalidValueWrite(ValueWriteError),
//TODO: This can be removed at some point //FIXME: This can be removed at some point
/// Failed to serialize struct, sequence or map, because its length is unknown. /// Failed to serialize struct, sequence or map, because its length is unknown.
UnknownLength, UnknownLength,
/// Invalid Data model, i.e. Serialize trait is not implmented correctly /// Invalid Data model, i.e. Serialize trait is not implmented correctly
@ -114,7 +114,7 @@ pub trait UnderlyingWrite {
/// ///
/// All instances of `ErrorKind::Interrupted` are handled by this function and the underlying /// All instances of `ErrorKind::Interrupted` are handled by this function and the underlying
/// operation is retried. /// operation is retried.
// TODO: Docs. Examples. // FIXME: Docs. Examples.
#[derive(Debug)] #[derive(Debug)]
pub struct Serializer<W, C = DefaultConfig> { pub struct Serializer<W, C = DefaultConfig> {
wr: W, wr: W,

View File

@ -32,7 +32,7 @@
/// ///
/// Example Serde impl for custom type: /// Example Serde impl for custom type:
/// ///
/// ```ignore /// ```ignore (this-shuts-tidy-up)
/// #[derive(Debug, PartialEq, Serialize, Deserialize)] /// #[derive(Debug, PartialEq, Serialize, Deserialize)]
/// #[serde(rename = "_ExtStruct")] /// #[serde(rename = "_ExtStruct")]
/// struct ExtStruct((i8, serde_bytes::ByteBuf)); /// struct ExtStruct((i8, serde_bytes::ByteBuf));

View File

@ -561,6 +561,9 @@
//@ revisions: x86_64_unknown_linux_none //@ revisions: x86_64_unknown_linux_none
//@ [x86_64_unknown_linux_none] compile-flags: --target x86_64-unknown-linux-none //@ [x86_64_unknown_linux_none] compile-flags: --target x86_64-unknown-linux-none
//@ [x86_64_unknown_linux_none] needs-llvm-components: x86 //@ [x86_64_unknown_linux_none] needs-llvm-components: x86
//@ revisions: x86_64_unknown_mikros
//@ [x86_64_unknown_mikros] compile-flags: --target x86_64-unknown-mikros
//@ [x86_64_unknown_mikros] needs-llvm-components: x86
//@ revisions: x86_64_unknown_netbsd //@ revisions: x86_64_unknown_netbsd
//@ [x86_64_unknown_netbsd] compile-flags: --target x86_64-unknown-netbsd //@ [x86_64_unknown_netbsd] compile-flags: --target x86_64-unknown-netbsd
//@ [x86_64_unknown_netbsd] needs-llvm-components: x86 //@ [x86_64_unknown_netbsd] needs-llvm-components: x86