Struct netcorehost::hostfxr::HostfxrContext
source · [−]pub struct HostfxrContext<I> { /* private fields */ }
Expand description
State which hostfxr creates and maintains and represents a logical operation on the hosting components.
Implementations
sourceimpl<I> HostfxrContext<I>
impl<I> HostfxrContext<I>
sourcepub unsafe fn from_handle(handle: HostfxrHandle, hostfxr: Hostfxr) -> Self
pub unsafe fn from_handle(handle: HostfxrHandle, hostfxr: Hostfxr) -> Self
Creates a new context from the given handle.
Safety
The context handle has to be match the context type I
.
If the context was initialized using initialize_for_dotnet_command_line
I
has to be InitializedForCommandLine
.
If the context was initialized using initialize_for_runtime_config
I
has to be InitializedForRuntimeConfig
.
sourcepub fn handle(&self) -> HostfxrHandle
pub fn handle(&self) -> HostfxrHandle
Gets the underlying handle to the hostfxr context.
sourcepub fn into_handle(self) -> HostfxrHandle
pub fn into_handle(self) -> HostfxrHandle
Gets the underlying handle to the hostfxr context and consume this context.
sourcepub fn get_runtime_property_value(
&self,
name: impl AsRef<PdCStr>
) -> Result<PdCString, HostingError>
pub fn get_runtime_property_value(
&self,
name: impl AsRef<PdCStr>
) -> Result<PdCString, HostingError>
Gets the runtime property value for the given key of this host context.
sourcepub unsafe fn get_runtime_property_value_ref(
&self,
name: impl AsRef<PdCStr>
) -> Result<&PdCStr, HostingError>
pub unsafe fn get_runtime_property_value_ref(
&self,
name: impl AsRef<PdCStr>
) -> Result<&PdCStr, HostingError>
Gets the runtime property value for the given key of this host context.
Safety
The value string is owned by the host context. The lifetime of the buffer is only guaranteed until any of the below occur:
run_app
is called for this host context- properties are changed via
set_runtime_property_value
orremove_runtime_property_value
sourcepub fn set_runtime_property_value(
&self,
name: impl AsRef<PdCStr>,
value: impl AsRef<PdCStr>
) -> Result<HostingSuccess, HostingError>
pub fn set_runtime_property_value(
&self,
name: impl AsRef<PdCStr>,
value: impl AsRef<PdCStr>
) -> Result<HostingSuccess, HostingError>
Sets the value of a runtime property for this host context.
sourcepub fn remove_runtime_property_value(
&self,
name: impl AsRef<PdCStr>
) -> Result<HostingSuccess, HostingError>
pub fn remove_runtime_property_value(
&self,
name: impl AsRef<PdCStr>
) -> Result<HostingSuccess, HostingError>
Remove a runtime property for this host context.
sourcepub unsafe fn get_runtime_properties_ref(
&self
) -> Result<(Vec<&PdCStr>, Vec<&PdCStr>), HostingError>
pub unsafe fn get_runtime_properties_ref(
&self
) -> Result<(Vec<&PdCStr>, Vec<&PdCStr>), HostingError>
Get all runtime properties for this host context.
Safety
The strings returned are owned by the host context. The lifetime of the buffers is only guaranteed until any of the below occur:
run_app
is called for this host context- properties are changed via
set_runtime_property_value
orremove_runtime_property_value
- the host context is dropped
sourcepub fn get_runtime_properties_owned(
&self
) -> Result<(Vec<PdCString>, Vec<PdCString>), HostingError>
pub fn get_runtime_properties_owned(
&self
) -> Result<(Vec<PdCString>, Vec<PdCString>), HostingError>
Get all runtime properties for this host context as owned strings.
sourcepub unsafe fn get_runtime_properties_ref_iter(
&self
) -> Result<impl Iterator<Item = (&PdCStr, &PdCStr)>, HostingError>
pub unsafe fn get_runtime_properties_ref_iter(
&self
) -> Result<impl Iterator<Item = (&PdCStr, &PdCStr)>, HostingError>
Get all runtime properties for this host context as an iterator over borrowed key-value pairs.
Safety
The strings returned are owned by the host context. The lifetime of the buffers is only guaranteed until any of the below occur:
run_app
is called for this host context- properties are changed via
set_runtime_property_value
orremove_runtime_property_value
- the host context is dropped
sourcepub fn get_runtime_properties_iter(
&self
) -> Result<impl Iterator<Item = (PdCString, PdCString)>, HostingError>
pub fn get_runtime_properties_iter(
&self
) -> Result<impl Iterator<Item = (PdCString, PdCString)>, HostingError>
Get all runtime properties for this host context as an iterator over owned key-value pairs.
sourcepub unsafe fn get_runtime_properties_ref_as_map(
&self
) -> Result<HashMap<&PdCStr, &PdCStr>, HostingError>
pub unsafe fn get_runtime_properties_ref_as_map(
&self
) -> Result<HashMap<&PdCStr, &PdCStr>, HostingError>
Get all runtime properties for this host context as an hashmap of borrowed strings.
Safety
The strings returned are owned by the host context. The lifetime of the buffers is only guaranteed until any of the below occur:
run_app
is called for this host context- properties are changed via
set_runtime_property_value
orremove_runtime_property_value
- the host context is dropped
sourcepub fn get_runtime_properties_as_map(
&self
) -> Result<HashMap<PdCString, PdCString>, HostingError>
pub fn get_runtime_properties_as_map(
&self
) -> Result<HashMap<PdCString, PdCString>, HostingError>
Get all runtime properties for this host context as an hashmap of owned strings.
sourcepub fn get_runtime_delegate(
&self,
type: hostfxr_delegate_type
) -> Result<RawFunctionPtr, HostingError>
pub fn get_runtime_delegate(
&self,
type: hostfxr_delegate_type
) -> Result<RawFunctionPtr, HostingError>
Gets a typed delegate from the currently loaded CoreCLR
or from a newly created one.
You propably want to use get_delegate_loader
or get_delegate_loader_for_assembly
instead of this function if you want to load function pointers.
Remarks
If the context was initialized using initialize_for_runtime_config
, then all delegate types are supported.
If it was initialized using initialize_for_dotnet_command_line
, then only the following
delegate types are currently supported:
sourcepub fn get_delegate_loader(&self) -> Result<DelegateLoader, HostingError>
pub fn get_delegate_loader(&self) -> Result<DelegateLoader, HostingError>
Gets a delegate loader for loading an assembly and contained function pointers.
sourcepub fn get_delegate_loader_for_assembly<A: AsRef<PdCStr>>(
&self,
assembly_path: A
) -> Result<AssemblyDelegateLoader<A>, HostingError>
pub fn get_delegate_loader_for_assembly<A: AsRef<PdCStr>>(
&self,
assembly_path: A
) -> Result<AssemblyDelegateLoader<A>, HostingError>
Gets a delegate loader for loading function pointers of the assembly with the given path. The assembly will be loaded lazily when the first function pointer is loaded.
sourcepub fn close(self) -> Result<HostingSuccess, HostingError>
pub fn close(self) -> Result<HostingSuccess, HostingError>
Closes an initialized host context.
This method is automatically called on drop, but can be explicitely called to handle errors during closing.
sourceimpl HostfxrContext<InitializedForCommandLine>
impl HostfxrContext<InitializedForCommandLine>
sourcepub fn run_app(self) -> AppOrHostingResult
pub fn run_app(self) -> AppOrHostingResult
Load the dotnet runtime and run the application.
Return value
If the app was successfully run, the exit code of the application. Otherwise, the error code result.
Trait Implementations
sourceimpl<I> DestructDrop for HostfxrContext<I>
impl<I> DestructDrop for HostfxrContext<I>
sourcefn destruct_drop(self)
fn destruct_drop(self)
Consume self without dropping it while dropping all of its contents normally.
Auto Trait Implementations
impl<I> RefUnwindSafe for HostfxrContext<I> where
I: RefUnwindSafe,
impl<I> !Send for HostfxrContext<I>
impl<I> !Sync for HostfxrContext<I>
impl<I> Unpin for HostfxrContext<I> where
I: Unpin,
impl<I> UnwindSafe for HostfxrContext<I> where
I: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more