Skip to main content

Fetch

Trait Fetch 

Source
pub trait Fetch:
    Send
    + Sync
    + FetchBytes {
    type T;

    // Required method
    fn fetch(&self) -> FailFuture<'_, Self::T>;

    // Provided methods
    fn try_fetch_local(&self) -> Result<Option<Self::T>> { ... }
    fn fetch_local(&self) -> Option<Self::T> { ... }
    fn get(&self) -> Option<&Self::T> { ... }
    fn get_mut(&mut self) -> Option<&mut Self::T> { ... }
    fn get_mut_finalize(&mut self) { ... }
    fn try_unwrap(self: Arc<Self>) -> Option<Self::T> { ... }
    fn into_dyn_fetch<'a>(self) -> Arc<dyn Fetch<T = Self::T> + 'a> 
       where Self: 'a + Sized { ... }
}
Expand description

Application-facing traversal.

Required Associated Types§

Source

type T

Fetched object.

Required Methods§

Source

fn fetch(&self) -> FailFuture<'_, Self::T>

Main traversal method.

Provided Methods§

Source

fn try_fetch_local(&self) -> Result<Option<Self::T>>

Attempt to fetch the object locally.

Generally this is either Fetch::get+Clone::clone or FetchBytes::fetch_bytes_local+Parse::parse.

Source

fn fetch_local(&self) -> Option<Self::T>

Fetch locally if possible. Typically this is just Fetch::get+Clone::clone.

Source

fn get(&self) -> Option<&Self::T>

Get a reference to a locally stored object.

Source

fn get_mut(&mut self) -> Option<&mut Self::T>

Get a mutable reference to a locally stored object.

Fetch::get_mut_finalize must be called to restore the state even if no mutations were made.

Source

fn get_mut_finalize(&mut self)

Restore the inner state after mutations completed (for example, [Hash] of what’s stored).

Source

fn try_unwrap(self: Arc<Self>) -> Option<Self::T>

Attempt unwrapping the object stored locally.

Source

fn into_dyn_fetch<'a>(self) -> Arc<dyn Fetch<T = Self::T> + 'a>
where Self: 'a + Sized,

Convenience method to force a conversion to a trait object.

Trait Implementations§

Source§

impl<T> ByteOrd for dyn Fetch<T = T> + '_

Source§

fn bytes_cmp(&self, _: &Self) -> Ordering

Source§

impl<T> Eq for dyn Fetch<T = T> + '_

Source§

impl<T> Hash for dyn Fetch<T = T> + '_

Source§

fn hash<H: Hasher>(&self, _: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl<T> InlineOutput for dyn Fetch<T = T> + '_

Source§

impl<T> Ord for dyn Fetch<T = T> + '_

Source§

fn cmp(&self, _: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl<T> PartialEq for dyn Fetch<T = T> + '_

Source§

fn eq(&self, _: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T> PartialOrd for dyn Fetch<T = T> + '_

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Tagged> Tagged for dyn Fetch<T = T> + '_

Source§

const TAGS: Tags = T::TAGS

Source§

const HASH: Hash = T::HASH

Source§

impl<T> ToOutput for dyn Fetch<T = T> + '_

Even though we refer to something, we don’t know [Hash] for it. To match correctness, we don’t implement Parse/ParseInline.

Source§

fn to_output(&self, _: &mut (impl ?Sized + Output))

Provide object’s byte representation to an Output.
Source§

fn hasher(&self) -> Sha256

Return a Sha256 hasher pre-filled with data of this object.
Source§

fn data_hash(&self) -> Hash

[Hash] of (real, i.e. serialized) data of this object.
Source§

fn mangle_hash(&self) -> Hash

“Mangle hash” of the object. This is used to introduce runtime distinction between data-identical objects similarly to compile-time Tagged::HASH.
Source§

fn output<T: FromOutput<Output: Default>>(&self) -> T

Construct an Output, possibly finalising it afterwards. Read more
Source§

fn vec(&self) -> Vec<u8>

Collect this object’s data (serialize the object).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: Fetch + Clone> Fetch for Arc<T>

Source§

type T = <T as Fetch>::T

Source§

fn fetch(&self) -> FailFuture<'_, Self::T>

Source§

fn try_fetch_local(&self) -> Result<Option<Self::T>>

Source§

fn fetch_local(&self) -> Option<Self::T>

Source§

fn get(&self) -> Option<&Self::T>

Source§

fn get_mut(&mut self) -> Option<&mut Self::T>

Source§

fn get_mut_finalize(&mut self)

Source§

fn try_unwrap(self: Arc<Self>) -> Option<Self::T>

Source§

fn into_dyn_fetch<'a>(self) -> Arc<dyn Fetch<T = Self::T> + 'a>
where Self: 'a + Sized,

Source§

impl<T> Fetch for Arc<dyn SingularFetch<T = T>>

Source§

type T = T

Source§

fn fetch(&self) -> FailFuture<'_, Self::T>

Source§

fn try_fetch_local(&self) -> Result<Option<Self::T>>

Source§

fn fetch_local(&self) -> Option<Self::T>

Source§

fn get(&self) -> Option<&Self::T>

Source§

fn into_dyn_fetch<'a>(self) -> Arc<dyn Fetch<T = Self::T> + 'a>
where Self: 'a + Sized,

Implementors§

Source§

impl<F: FetchFn<T: Traversible>> Fetch for FnFetch<F>

Source§

type T = <F as FetchFn>::T

Source§

impl<T: FullHash, Extra: Send + Sync + ExtraFor<T>> Fetch for Addressed<T, Extra>

Source§

type T = T

Source§

impl<T: Traversible + Clone> Fetch for Local<T>

Source§

type T = T