Enum casper_node::utils::External[][src]

pub enum External<T> {
    Path(PathBuf),
    Loaded(T),
    Missing,
}

External resource.

An External resource can be given in two ways: Either as an immediate value, or through a path, provided the value implements Loadable.

Serializing and deserializing an External value is only possible if it is in path form. This is especially useful when writing structure configurations.

An External also always provides a default, which will always result in an error when load is called. Should the underlying type T implement Default, the with_default can be used instead.

Variants

Path(PathBuf)

Value that should be loaded from an external path.

Loaded(T)

Loaded or immediate value.

Missing

The value has not been specified, but a default has been requested.

Implementations

impl<T> External<T>[src]

pub fn from_value(value: T) -> Self[src]

Creates an external from a value.

pub fn from_path<P: AsRef<Path>>(path: P) -> Self[src]

Creates an external referencing a path.

impl<T> External<T> where
    T: Loadable
[src]

pub fn load<P: AsRef<Path>>(self, root: P) -> Result<T, LoadError<T::Error>>[src]

Loads the value if not loaded already, resolving relative paths from root or returns available value. If the value is Missing, returns an error.

pub fn full_path<P: AsRef<Path>>(&self, root: P) -> Option<PathBuf>[src]

Returns the full path to the external item, or None if the type is Loaded or Missing.

impl<T> External<T> where
    T: Loadable + Default
[src]

pub fn with_default(self) -> Self[src]

Insert a default value if missing.

Trait Implementations

impl<T: Clone> Clone for External<T>[src]

impl<T> DataSize for External<T> where
    PathBuf: DataSize,
    T: DataSize
[src]

impl<T: Debug> Debug for External<T>[src]

impl<T> Default for External<T>[src]

impl<'de, T> Deserialize<'de> for External<T>[src]

impl<T: Eq> Eq for External<T>[src]

impl<T: PartialEq> PartialEq<External<T>> for External<T>[src]

impl<T> Serialize for External<T>[src]

impl<T> StructuralEq for External<T>[src]

impl<T> StructuralPartialEq for External<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for External<T> where
    T: RefUnwindSafe

impl<T> Send for External<T> where
    T: Send

impl<T> Sync for External<T> where
    T: Sync

impl<T> Unpin for External<T> where
    T: Unpin

impl<T> UnwindSafe for External<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Any + Send + Sync

impl<T> DynClone for T where
    T: Clone
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Serialize for T where
    T: Serialize + ?Sized
[src]

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]