pub enum Discriminator {
Known(VariantId),
Invalid,
Branch {
offset: ByteCount,
int_ty: IntegerTy,
children: Vec<(RangeInclusive<ScalarValue>, Discriminator)>,
fallback: Box<Discriminator>,
},
}Expand description
Decision tree used to determine the active variant by reading memory. Mirrors MiniRust’s
Discriminator.
Variants§
Known(VariantId)
The variant is known.
Invalid
No valid variant (e.g., invalid tag value).
Branch
Branch on an integer value read from memory at offset.
Fields
§
children: Vec<(RangeInclusive<ScalarValue>, Discriminator)>If the integer is in one of these ranges, continue with the given Discriminator. The
ranges are sorted.
§
fallback: Box<Discriminator>Fallback if no range in children matches.
Implementations§
Source§impl Discriminator
impl Discriminator
Sourcepub fn trivial(variant_id: VariantId) -> Self
pub fn trivial(variant_id: VariantId) -> Self
Make a trivial discriminator that always returns the given variant id.
Sourcepub fn read_discriminant(
&self,
read: impl Fn(ByteCount, IntegerTy) -> Result<ScalarValue, DiscriminantReadError> + Copy,
) -> Result<VariantId, DiscriminantReadError>
pub fn read_discriminant( &self, read: impl Fn(ByteCount, IntegerTy) -> Result<ScalarValue, DiscriminantReadError> + Copy, ) -> Result<VariantId, DiscriminantReadError>
Read a discriminant from memory. The read function simulates reading an integer of the
given type at the given byte offset from memory and can return UninitByte if the byte
could not be read.
Trait Implementations§
Source§impl Clone for Discriminator
impl Clone for Discriminator
Source§fn clone(&self) -> Discriminator
fn clone(&self) -> Discriminator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Discriminator
impl Debug for Discriminator
Source§impl<'de> Deserialize<'de> for Discriminator
impl<'de> Deserialize<'de> for Discriminator
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for Discriminator
impl PartialEq for Discriminator
Source§impl Serialize for Discriminator
impl Serialize for Discriminator
impl Eq for Discriminator
impl StructuralPartialEq for Discriminator
Auto Trait Implementations§
impl Freeze for Discriminator
impl RefUnwindSafe for Discriminator
impl Send for Discriminator
impl Sync for Discriminator
impl Unpin for Discriminator
impl UnwindSafe for Discriminator
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Given the context attached to a nom error, and given the original
input to the nom parser, extract more the useful context information. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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§impl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Given the original input, as well as the context reported by nom,
recreate a context in the original string where the error occurred. Read more