Skip to content

Commit

Permalink
misc cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes committed Jan 23, 2023
1 parent 1a2c446 commit 3bd2990
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 23 deletions.
6 changes: 3 additions & 3 deletions ssz-rs/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use crate::ser::SerializeError;
// Top-level error to wrap all child errors in crate
#[derive(Debug)]
pub enum Error {
Serialize(/*#[from]*/ SerializeError),
Deserialize(/*#[from]*/ DeserializeError),
Merkleization(/*#[from]*/ MerkleizationError),
Serialize(SerializeError),
Deserialize(DeserializeError),
Merkleization(MerkleizationError),
}

impl From<SerializeError> for Error {
Expand Down
4 changes: 2 additions & 2 deletions ssz-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ mod lib {
pub use std::*;
}

pub use self::core::{any, cmp, iter, slice};
pub use self::core::{any, cmp, fmt, iter, slice};

pub use self::cmp::Ordering;
pub use self::core::array::TryFromSliceError;
pub use self::core::fmt::{self, Debug, Display, Formatter};
pub use self::core::fmt::{Debug, Display, Formatter};
pub use self::core::ops::{Deref, DerefMut, Index, IndexMut};
pub use self::core::slice::{IterMut, SliceIndex};
pub use self::iter::Enumerate;
Expand Down
6 changes: 3 additions & 3 deletions ssz-rs/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use crate::merkleization::{
use crate::ser::{serialize_composite, Serialize, SerializeError};
use crate::{SimpleSerialize, Sized};
#[cfg(feature = "serde")]
use core::marker::PhantomData;
#[cfg(feature = "serde")]
use serde::ser::SerializeSeq;
#[cfg(feature = "serde")]
use std::marker::PhantomData;

/// A homogenous collection of a variable number of values.
#[derive(Clone, Default)]
Expand Down Expand Up @@ -287,7 +287,7 @@ pub struct IterMut<'a, T, const N: usize>
where
T: SimpleSerialize,
{
inner: Enumerate<crate::lib::IterMut<'a, T>>,
inner: Enumerate<slice::IterMut<'a, T>>,
cache: &'a mut MerkleCache,
}

Expand Down
10 changes: 2 additions & 8 deletions ssz-rs/src/merkleization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ pub trait Merkleized {

#[derive(Debug)]
pub enum MerkleizationError {
// #[error("failed to serialize value: {0}")]
SerializationError(/*#[from]*/ SerializeError),
// #[error("cannot merkleize data that exceeds the declared limit {0}")]
SerializationError(SerializeError),
InputExceedsLimit(usize),
}

Expand All @@ -33,15 +31,11 @@ impl From<SerializeError> for MerkleizationError {

impl Display for MerkleizationError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "the value could not be merkleized: ")?;
match self {
Self::SerializationError(err) => {
write!(f, "failed to serialize value: {err}")
}
Self::InputExceedsLimit(size) => write!(
f,
"cannot merkleize data that exceeds the declared limit: {size}",
),
Self::InputExceedsLimit(size) => write!(f, "data exceeds the declared limit {size}"),
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions ssz-rs/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ const MAXIMUM_LENGTH: u64 = 2u64.pow((8 * BYTES_PER_LENGTH_OFFSET) as u32);

#[derive(Debug)]
pub enum SerializeError {
// #[error("the encoded length is {0} which exceeds the maximum length {MAXIMUM_LENGTH}")]
MaximumEncodedLengthExceeded(usize),
// #[error("invalid instance: {0}")]
InvalidInstance(/*#[from]*/ InstanceError),
// #[error("invalid type: {0}")]
InvalidType(/*#[from]*/ TypeError),
InvalidInstance(InstanceError),
InvalidType(TypeError),
}

impl From<InstanceError> for SerializeError {
Expand Down
4 changes: 2 additions & 2 deletions ssz-rs/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use crate::merkleization::{
use crate::ser::{serialize_composite, Serialize, SerializeError};
use crate::{SimpleSerialize, Sized};
#[cfg(feature = "serde")]
use core::marker::PhantomData;
#[cfg(feature = "serde")]
use serde::ser::SerializeSeq;
#[cfg(feature = "serde")]
use std::marker::PhantomData;

/// A homogenous collection of a fixed number of values.
/// NOTE: a `Vector` of length `0` is illegal.
Expand Down

0 comments on commit 3bd2990

Please sign in to comment.