mirror of
https://github.com/pykeio/ort
synced 2026-04-25 16:34:55 +02:00
fix: --no-default-features build
This commit is contained in:
@@ -10,7 +10,7 @@ use std::{
|
||||
str
|
||||
};
|
||||
|
||||
use crate::{Error, ResultExt};
|
||||
use crate::error::{Error, ResultExt};
|
||||
|
||||
fn parse_octal(bytes: &[u8]) -> io::Result<u64> {
|
||||
let s = bytes.iter().take_while(|v| **v != 0).map(|v| *v as char).collect::<String>();
|
||||
|
||||
@@ -12,7 +12,7 @@ use ureq::{
|
||||
tls::{RootCerts, TlsConfig, TlsProvider}
|
||||
};
|
||||
|
||||
use crate::{Error, log, vars};
|
||||
use crate::{error::Error, log, vars};
|
||||
|
||||
mod extract;
|
||||
mod resolve;
|
||||
|
||||
34
ort-sys/build/error.rs
Normal file
34
ort-sys/build/error.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Error {
|
||||
message: String
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn new(message: impl Into<String>) -> Self {
|
||||
Self { message: message.into() }
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(&self.message)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: std::error::Error> From<E> for Error {
|
||||
fn from(value: E) -> Self {
|
||||
Self { message: value.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ResultExt<T, E> {
|
||||
fn with_context<S: fmt::Display, F: FnOnce() -> S>(self, ctx: F) -> Result<T, Error>;
|
||||
}
|
||||
|
||||
impl<T, E: fmt::Display> ResultExt<T, E> for Result<T, E> {
|
||||
fn with_context<S: fmt::Display, F: FnOnce() -> S>(self, ctx: F) -> Result<T, Error> {
|
||||
self.map_err(|e| Error::new(format!("{}: {}", ctx(), e)))
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
use std::{
|
||||
env,
|
||||
fmt::{self, Display},
|
||||
path::PathBuf
|
||||
};
|
||||
use std::{env, path::PathBuf};
|
||||
|
||||
#[cfg(feature = "download-binaries")]
|
||||
mod download;
|
||||
mod dynamic_link;
|
||||
#[cfg(feature = "download-binaries")]
|
||||
mod error;
|
||||
mod log;
|
||||
#[cfg(feature = "pkg-config")]
|
||||
mod pkg_config;
|
||||
@@ -162,36 +160,3 @@ cargo::error= | The downloaded binaries are available to inspect at: {}",
|
||||
println!("cargo:rustc-link-lib=static=onnxruntime");
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Error {
|
||||
message: String
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn new(message: impl Into<String>) -> Self {
|
||||
Self { message: message.into() }
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(&self.message)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: std::error::Error> From<E> for Error {
|
||||
fn from(value: E) -> Self {
|
||||
Self { message: value.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
trait ResultExt<T, E> {
|
||||
fn with_context<S: fmt::Display, F: FnOnce() -> S>(self, ctx: F) -> Result<T, Error>;
|
||||
}
|
||||
|
||||
impl<T, E: fmt::Display> ResultExt<T, E> for Result<T, E> {
|
||||
fn with_context<S: fmt::Display, F: FnOnce() -> S>(self, ctx: F) -> Result<T, Error> {
|
||||
self.map_err(|e| Error::new(format!("{}: {}", ctx(), e)))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user