From 73535fcf7da1ca327b019272f9f48e884fc80753 Mon Sep 17 00:00:00 2001 From: timofey Date: Fri, 5 May 2023 21:30:41 +0000 Subject: [PATCH] A/a_ prefixes for Atomic to allow for Factory parsing later --- src/std/atomic.rs | 16 ++++++++-------- src/std/atomic/atomic_object.rs | 6 +++--- src/std/atomic/boolean.rs | 6 +++--- src/std/atomic/plain.rs | 6 +++--- src/std/collections/rbtree.rs | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/std/atomic.rs b/src/std/atomic.rs index 75c2581..afb13b5 100644 --- a/src/std/atomic.rs +++ b/src/std/atomic.rs @@ -15,32 +15,32 @@ use super::*; /// while limiting [`Mentionable::points`] (and corresponding [`Mentionable::topology`]) to an empty sequence. pub trait Atomic: 'static + Send + Sync + Send + Clone + Serializable { /// Equivalent of [`Factory::ParseError`]. - type ParseError: Error; + type AParseError: Error; /// Static equivalent of [`Factory::deserialize`]. - fn deserialize(deserializer: &mut dyn Deserializer) -> Result; + fn a_deserialize(deserializer: &mut dyn Deserializer) -> Result; /// Static equivalent of [`Factory::unexpected_tail`]. - fn unexpected_tail(tail: &[u8]) -> Self::ParseError; + fn a_unexpected_tail(tail: &[u8]) -> Self::AParseError; } -fn _parse_slice(slice: &[u8]) -> Result { +fn _parse_slice(slice: &[u8]) -> Result { let mut deserializer = SliceDeserializer::from(slice); - let mentionable = A::deserialize(&mut deserializer)?; + let mentionable = A::a_deserialize(&mut deserializer)?; let tail = deserializer.read_all(); if tail.is_empty() { Ok(mentionable) } else { - Err(A::unexpected_tail(tail)) + Err(A::a_unexpected_tail(tail)) } } /// Extension trait to provide method-like utilities associated with [Atomic]s. pub trait ExtAtomic: Atomic { /// Static equivalent of [`ExtFactory::parse_slice`]. - fn parse_slice(slice: &[u8]) -> Result; + fn parse_slice(slice: &[u8]) -> Result; } impl ExtAtomic for A { - fn parse_slice(slice: &[u8]) -> Result { + fn parse_slice(slice: &[u8]) -> Result { _parse_slice(slice) } } diff --git a/src/std/atomic/atomic_object.rs b/src/std/atomic/atomic_object.rs index 9f1782a..0e45b73 100644 --- a/src/std/atomic/atomic_object.rs +++ b/src/std/atomic/atomic_object.rs @@ -69,7 +69,7 @@ impl Clone for AtomicFactory { impl<'a, Ctx: 'a + Context, A: Atomic> Factory<'a, Ctx> for AtomicFactory { type Mtbl = AtomicObject; - type ParseError = A::ParseError; + type ParseError = A::AParseError; fn deserialize( &self, @@ -77,11 +77,11 @@ impl<'a, Ctx: 'a + Context, A: Atomic> Factory<'a, Ctx> for AtomicFactory { _resolver: Rc>, _addresses: &mut Addresses, ) -> ParseResult<'a, Ctx, Self> { - Ok(A::deserialize(deserializer)?.into()) + Ok(A::a_deserialize(deserializer)?.into()) } fn unexpected_tail(&self, tail: &[u8]) -> Self::ParseError { - A::unexpected_tail(tail) + A::a_unexpected_tail(tail) } } diff --git a/src/std/atomic/boolean.rs b/src/std/atomic/boolean.rs index 3b590e4..c38f212 100644 --- a/src/std/atomic/boolean.rs +++ b/src/std/atomic/boolean.rs @@ -44,9 +44,9 @@ impl From<&[u8]> for BooleanParseError { } impl Atomic for bool { - type ParseError = BooleanParseError; + type AParseError = BooleanParseError; - fn deserialize(deserializer: &mut dyn Deserializer) -> Result { + fn a_deserialize(deserializer: &mut dyn Deserializer) -> Result { let byte = deserializer.read_n_const::<1>()?; match byte[0] { 0 => Ok(false), @@ -55,7 +55,7 @@ impl Atomic for bool { } } - fn unexpected_tail(tail: &[u8]) -> Self::ParseError { + fn a_unexpected_tail(tail: &[u8]) -> Self::AParseError { BooleanParseError::ExtraData(tail.len()) } } diff --git a/src/std/atomic/plain.rs b/src/std/atomic/plain.rs index 0c9a408..19b40e1 100644 --- a/src/std/atomic/plain.rs +++ b/src/std/atomic/plain.rs @@ -29,13 +29,13 @@ impl Serializable for Plain { } impl Atomic for Plain { - type ParseError = PlainParseError; + type AParseError = PlainParseError; - fn deserialize(deserializer: &mut dyn Deserializer) -> Result { + fn a_deserialize(deserializer: &mut dyn Deserializer) -> Result { Ok(Plain::from_slice(deserializer.read_all())) } - fn unexpected_tail(tail: &[u8]) -> Self::ParseError { + fn a_unexpected_tail(tail: &[u8]) -> Self::AParseError { panic!( "Plain must use read_all, therefore there must not be any extra tail (received {} bytes).", tail.len() diff --git a/src/std/collections/rbtree.rs b/src/std/collections/rbtree.rs index 67f0a34..9783af7 100644 --- a/src/std/collections/rbtree.rs +++ b/src/std/collections/rbtree.rs @@ -183,7 +183,7 @@ impl<'a, Ctx: 'a + Context, F: Factory<'a, Ctx>> Factory<'a, Ctx> for RBFactory< resolver: std::rc::Rc>, addresses: &mut Addresses, ) -> ParseResult<'a, Ctx, Self> { - let rb = RB::deserialize(deserializer)?; + let rb = RB::a_deserialize(deserializer)?; Ok(match rb { R => RBNode::R( RFactory {