Struct netcorehost::error::HostingResult
source · #[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
impl HostingResult
sourcepub const fn from_status_code(code: u32) -> Self
pub const fn from_status_code(code: u32) -> Self
Creates a new HostingResult
from the raw status code.
sourcepub const fn from_success(success: HostingSuccess) -> Self
pub const fn from_success(success: HostingSuccess) -> Self
Creates a new successful HostingResult
from the give HostingSuccess
.
sourcepub const fn from_error(error: HostingError) -> Self
pub const fn from_error(error: HostingError) -> Self
Creates a new erroneous HostingResult
from the give HostingError
.
sourcepub const fn known_from_status_code(code: u32) -> Result<Self, u32>
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
.
sourcepub fn is_known(&self) -> bool
pub fn is_known(&self) -> bool
Returns whether the status code of this result has a known meaning.
sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Returns whether the status code of this result has a unknown meaning.
sourcepub fn into_result(&self) -> Result<HostingSuccess, HostingError>
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 · sourcepub fn as_ref(&self) -> Result<&T, &E>
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 · sourcepub fn as_deref(&self) -> Result<&<T as Deref>::Target, &E>where
T: Deref,
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 · sourcepub fn iter(&self) -> Iter<'_, T>
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
impl Clone for HostingResult
source§fn clone(&self) -> HostingResult
fn clone(&self) -> HostingResult
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for HostingResult
impl Debug for HostingResult
source§impl Deref for HostingResult
impl Deref for HostingResult
§type Target = Result<HostingSuccess, HostingError>
type Target = Result<HostingSuccess, HostingError>
source§impl From<HostingError> for HostingResult
impl From<HostingError> for HostingResult
source§fn from(error: HostingError) -> Self
fn from(error: HostingError) -> Self
source§impl From<HostingResult> for i32
impl From<HostingResult> for i32
source§fn from(code: HostingResult) -> Self
fn from(code: HostingResult) -> Self
source§impl From<HostingResult> for u32
impl From<HostingResult> for u32
source§fn from(code: HostingResult) -> Self
fn from(code: HostingResult) -> Self
source§impl From<HostingSuccess> for HostingResult
impl From<HostingSuccess> for HostingResult
source§fn from(success: HostingSuccess) -> Self
fn from(success: HostingSuccess) -> Self
source§impl From<Result<HostingSuccess, HostingError>> for HostingResult
impl From<Result<HostingSuccess, HostingError>> for HostingResult
source§fn from(original: Result<HostingSuccess, HostingError>) -> HostingResult
fn from(original: Result<HostingSuccess, HostingError>) -> HostingResult
source§impl From<i32> for HostingResult
impl From<i32> for HostingResult
source§impl From<u32> for HostingResult
impl From<u32> for HostingResult
source§impl FromResidual for HostingResult
impl FromResidual for HostingResult
source§fn from_residual(r: HostingError) -> Self
fn from_residual(r: HostingError) -> Self
try_trait_v2
)Residual
type. Read moresource§impl Hash for HostingResult
impl Hash for HostingResult
source§impl Ord for HostingResult
impl Ord for HostingResult
source§fn cmp(&self, other: &HostingResult) -> Ordering
fn cmp(&self, other: &HostingResult) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for HostingResult
impl PartialEq for HostingResult
source§fn eq(&self, other: &HostingResult) -> bool
fn eq(&self, other: &HostingResult) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for HostingResult
impl PartialOrd for HostingResult
source§fn partial_cmp(&self, other: &HostingResult) -> Option<Ordering>
fn partial_cmp(&self, other: &HostingResult) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Try for HostingResult
impl Try for HostingResult
§type Output = HostingSuccess
type Output = HostingSuccess
try_trait_v2
)?
when not short-circuiting.§type Residual = HostingError
type Residual = HostingError
try_trait_v2
)FromResidual::from_residual
as part of ?
when short-circuiting. Read moresource§fn branch(self) -> ControlFlow<Self::Residual, Self::Output>
fn branch(self) -> ControlFlow<Self::Residual, Self::Output>
try_trait_v2
)?
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 moresource§fn from_output(code: HostingSuccess) -> Self
fn from_output(code: HostingSuccess) -> Self
try_trait_v2
)Output
type. Read more