Skip to content

Commit 0e1affd

Browse files
author
Thomas Bächler
committed
Fix compilation without the nethost feature.
1 parent 2122bc5 commit 0e1affd

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

src/error/load_hostfxr_error.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use crate::error::HostingError;
2+
use thiserror::Error;
3+
4+
/// Enum for errors that can occur while locating and loading the hostfxr library.
5+
#[derive(Debug, Error)]
6+
pub enum LoadHostfxrError {
7+
/// An error occured inside the hosting components.
8+
#[error(transparent)]
9+
Hosting(#[from] HostingError),
10+
/// An error occured while loading the hostfxr library.
11+
#[error(transparent)]
12+
DlOpen(#[from] crate::dlopen2::Error),
13+
}

src/error/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
mod hosting_result;
22
pub use hosting_result::*;
33

4+
mod load_hostfxr_error;
5+
pub use load_hostfxr_error::*;
6+
47
mod univ;
58
pub use univ::*;

src/error/univ.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ pub enum Error {
1313
GetFunctionPointer(#[from] crate::hostfxr::GetManagedFunctionError),
1414
/// An error while loading the hostfxr library.
1515
#[error(transparent)]
16-
LoadHostfxr(#[from] crate::nethost::LoadHostfxrError),
16+
LoadHostfxr(#[from] crate::error::LoadHostfxrError),
1717
}
1818

1919
impl From<crate::dlopen2::Error> for Error {
2020
fn from(err: crate::dlopen2::Error) -> Self {
21-
Self::LoadHostfxr(crate::nethost::LoadHostfxrError::DlOpen(err))
21+
Self::LoadHostfxr(crate::error::LoadHostfxrError::DlOpen(err))
2222
}
2323
}

src/hostfxr/library.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::{
22
dlopen2::wrapper::Container,
3-
error::{HostingError, HostingResult},
4-
nethost::LoadHostfxrError,
3+
error::{HostingError, HostingResult, LoadHostfxrError},
54
pdcstring::PdCString,
65
};
76
use derive_more::From;

src/nethost.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use crate::{
55
pdcstring::{self, PdCStr, PdUChar},
66
};
77
use std::{ffi::OsString, mem::MaybeUninit, ptr};
8-
use thiserror::Error;
8+
9+
#[doc(no_inline)]
10+
pub use crate::error::LoadHostfxrError;
911

1012
/// Gets the path to the hostfxr library.
1113
pub fn get_hostfxr_path() -> Result<OsString, HostingError> {
@@ -100,17 +102,6 @@ pub fn load_hostfxr_with_dotnet_root<P: AsRef<PdCStr>>(
100102
Ok(hostfxr)
101103
}
102104

103-
/// Enum for errors that can occur while locating and loading the hostfxr library.
104-
#[derive(Debug, Error)]
105-
pub enum LoadHostfxrError {
106-
/// An error occured inside the hosting components.
107-
#[error(transparent)]
108-
Hosting(#[from] HostingError),
109-
/// An error occured while loading the hostfxr library.
110-
#[error(transparent)]
111-
DlOpen(#[from] crate::dlopen2::Error),
112-
}
113-
114105
const unsafe fn maybe_uninit_slice_assume_init_ref<T>(slice: &[MaybeUninit<T>]) -> &[T] {
115106
#[cfg(feature = "nightly")]
116107
unsafe {

0 commit comments

Comments
 (0)