pub struct Location<'t, T>where
T: CustomTraversal,{
pub start_offset: usize,
pub end_offset: usize,
pub ancestor_path: &'t [AncestorState<T>],
}
Expand description
The Location of the encoding - capturing both the byte offset in the payload, and also the container-path-based location in the SBOR value model.
Fields§
§start_offset: usize
An offset in the payload, where this Location
starts.
The meaning of this offset depends on the context of the event, eg:
- For ContainerStart, this is the start of the value
- For ContainerEnd, this is the start of the value
- For DecodeError, this is the location where the error occurred
end_offset: usize
An offset in the payload, where this Location
ends (could be the same as start_offset).
The meaning of this offset depends on the context of the event, eg:
- For ContainerStart, this is the end of the header
- For ContainerEnd, this is the end of the whole container value
- For DecodeError, this is the location where the error occurred
ancestor_path: &'t [AncestorState<T>]
The path of containers from the root to the current value. All containers in this list have current_child_index
set.
Note that for certain events:
- For ContainerStart/ContainerEnd, this does NOT include the newly started/ended container.
- For TerminalValue/TerminalValueBatch, this includes all ancestors of that value/value batch.
- For DecodeError, it only includes ancestors where we have started to read their children.
- For End, this is an empty slice
Implementations§
Source§impl<'t, T> Location<'t, T>where
T: CustomTraversal,
impl<'t, T> Location<'t, T>where
T: CustomTraversal,
pub fn get_latest_ancestor(&self) -> Option<&AncestorState<T>>
Sourcepub fn get_start_offset_of_value_body(&self) -> usize
pub fn get_start_offset_of_value_body(&self) -> usize
Gives the offset of the start of the value body (ignoring the value kind byte). The result is only valid if this location corresponds to a ContainerStart/TerminalValue/ContainerEnd event.
Trait Implementations§
impl<'t, T> Copy for Location<'t, T>where
T: Copy + CustomTraversal,
impl<'t, T> Eq for Location<'t, T>where
T: Eq + CustomTraversal,
impl<'t, T> StructuralPartialEq for Location<'t, T>where
T: CustomTraversal,
Auto Trait Implementations§
impl<'t, T> Freeze for Location<'t, T>
impl<'t, T> RefUnwindSafe for Location<'t, T>
impl<'t, T> Send for Location<'t, T>
impl<'t, T> Sync for Location<'t, T>
impl<'t, T> Unpin for Location<'t, T>
impl<'t, T> UnwindSafe for Location<'t, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U> ContextualTryInto<U> for Twhere
U: ContextualTryFrom<T>,
impl<T, U> ContextualTryInto<U> for Twhere
U: ContextualTryFrom<T>,
type Error = <U as ContextualTryFrom<T>>::Error
type Context = <U as ContextualTryFrom<T>>::Context
fn contextual_try_into( self, context: &<U as ContextualTryFrom<T>>::Context, ) -> Result<U, <U as ContextualTryFrom<T>>::Error>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more