#[repr(transparent)]
pub struct HostingResult(pub Result<HostingSuccess, HostingError>);
Expand description

Result of a hosting API operation of hostfxr, hostpolicy and nethost.

Source: https://github.com/dotnet/runtime/blob/main/docs/design/features/host-error-codes.md

Tuple Fields§

§0: Result<HostingSuccess, HostingError>

Implementations§

source§

impl HostingResult

source

pub const fn from_status_code(code: u32) -> Self

Creates a new HostingResult from the raw status code.

source

pub const fn from_success(success: HostingSuccess) -> Self

Creates a new successful HostingResult from the give HostingSuccess.

source

pub const fn from_error(error: HostingError) -> Self

Creates a new erroneous HostingResult from the give HostingError.

source

pub const fn known_from_status_code(code: u32) -> Result<Self, u32>

Tries to create a new HostingResult from the raw status code if it is known. Otherwise returns the given value as an Err.

source

pub fn value(&self) -> u32

Returns the underlying status code value.

source

pub fn is_known(&self) -> bool

Returns whether the status code of this result has a known meaning.

source

pub fn is_unknown(&self) -> bool

Returns whether the status code of this result has a unknown meaning.

source

pub fn into_result(&self) -> Result<HostingSuccess, HostingError>

Transforms the result into a Result<HostingSuccess, HostingError>.

Methods from Deref<Target = Result<HostingSuccess, HostingError>>§

1.0.0 · source

pub fn is_ok(&self) -> bool

Returns true if the result is Ok.

§Examples
let x: Result<i32, &str> = Ok(-3);
assert_eq!(x.is_ok(), true);

let x: Result<i32, &str> = Err("Some error message");
assert_eq!(x.is_ok(), false);
1.0.0 · source

pub fn is_err(&self) -> bool

Returns true if the result is Err.

§Examples
let x: Result<i32, &str> = Ok(-3);
assert_eq!(x.is_err(), false);

let x: Result<i32, &str> = Err("Some error message");
assert_eq!(x.is_err(), true);
1.0.0 · source

pub fn as_ref(&self) -> Result<&T, &E>

Converts from &Result<T, E> to Result<&T, &E>.

Produces a new Result, containing a reference into the original, leaving the original in place.

§Examples
let x: Result<u32, &str> = Ok(2);
assert_eq!(x.as_ref(), Ok(&2));

let x: Result<u32, &str> = Err("Error");
assert_eq!(x.as_ref(), Err(&"Error"));
1.47.0 · source

pub fn as_deref(&self) -> Result<&<T as Deref>::Target, &E>
where T: Deref,

Converts from Result<T, E> (or &Result<T, E>) to Result<&<T as Deref>::Target, &E>.

Coerces the Ok variant of the original Result via Deref and returns the new Result.

§Examples
let x: Result<String, u32> = Ok("hello".to_string());
let y: Result<&str, &u32> = Ok("hello");
assert_eq!(x.as_deref(), y);

let x: Result<String, u32> = Err(42);
let y: Result<&str, &u32> = Err(&42);
assert_eq!(x.as_deref(), y);
1.0.0 · source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over the possibly contained value.

The iterator yields one value if the result is Result::Ok, otherwise none.

§Examples
let x: Result<u32, &str> = Ok(7);
assert_eq!(x.iter().next(), Some(&7));

let x: Result<u32, &str> = Err("nothing!");
assert_eq!(x.iter().next(), None);

Trait Implementations§

source§

impl Clone for HostingResult

source§

fn clone(&self) -> HostingResult

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for HostingResult

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deref for HostingResult

§

type Target = Result<HostingSuccess, HostingError>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl From<HostingError> for HostingResult

source§

fn from(error: HostingError) -> Self

Converts to this type from the input type.
source§

impl From<HostingResult> for i32

source§

fn from(code: HostingResult) -> Self

Converts to this type from the input type.
source§

impl From<HostingResult> for u32

source§

fn from(code: HostingResult) -> Self

Converts to this type from the input type.
source§

impl From<HostingSuccess> for HostingResult

source§

fn from(success: HostingSuccess) -> Self

Converts to this type from the input type.
source§

impl From<Result<HostingSuccess, HostingError>> for HostingResult

source§

fn from(original: Result<HostingSuccess, HostingError>) -> HostingResult

Converts to this type from the input type.
source§

impl From<i32> for HostingResult

source§

fn from(code: i32) -> Self

Converts to this type from the input type.
source§

impl From<u32> for HostingResult

source§

fn from(code: u32) -> Self

Converts to this type from the input type.
source§

impl FromResidual for HostingResult

source§

fn from_residual(r: HostingError) -> Self

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from a compatible Residual type. Read more
source§

impl Hash for HostingResult

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for HostingResult

source§

fn cmp(&self, other: &HostingResult) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for HostingResult

source§

fn eq(&self, other: &HostingResult) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for HostingResult

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Try for HostingResult

§

type Output = HostingSuccess

🔬This is a nightly-only experimental API. (try_trait_v2)
The type of the value produced by ? when not short-circuiting.
§

type Residual = HostingError

🔬This is a nightly-only experimental API. (try_trait_v2)
The type of the value passed to FromResidual::from_residual as part of ? when short-circuiting. Read more
source§

fn branch(self) -> ControlFlow<Self::Residual, Self::Output>

🔬This is a nightly-only experimental API. (try_trait_v2)
Used in ? to decide whether the operator should produce a value (because this returned ControlFlow::Continue) or propagate a value back to the caller (because this returned ControlFlow::Break). Read more
source§

fn from_output(code: HostingSuccess) -> Self

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from its Output type. Read more
source§

impl Copy for HostingResult

source§

impl Eq for HostingResult

source§

impl StructuralPartialEq for HostingResult

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.