This repository was archived by the owner on Mar 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 143
updates to core #222
Merged
Merged
updates to core #222
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Cargo.lock | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
[package] | ||
authors = ["The Hyperledger Ursa Contributors"] | ||
description = "Core functionality shared across all ursa components" | ||
edition = "2018" | ||
documentation = "https://docs.rs/ursa_core" | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
name = "ursa_core" | ||
readme = "../README.md" | ||
version = "0.5.0" | ||
|
||
[dependencies] | ||
anyhow = "1.0" | ||
core2 = "0.4" | ||
serde = "1.0" | ||
serde_bare = "0.5" | ||
serde_cbor = "0.11" | ||
serde_json = "1.0" | ||
string-error = "0.1" | ||
thiserror = "1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use string_error::*; | ||
use thiserror::Error as ThisError; | ||
|
||
/// The common errors that can occur in Ursa | ||
#[derive(ThisError, Debug)] | ||
#[non_exhaustive] | ||
pub enum UrsaError { | ||
/// Convert IO errors | ||
#[error("io error")] | ||
IoError(#[from] core2::io::Error), | ||
/// Convert format errors | ||
#[error("fmt error")] | ||
FmtError(#[from] std::fmt::Error), | ||
/// Convert parse bool from string errors | ||
#[error("parse bool error")] | ||
ParseBoolError(#[from] std::str::ParseBoolError), | ||
#[error("environment variable error")] | ||
/// Convert environment variable errors | ||
EnvVarError(#[from] std::env::VarError), | ||
/// Convert json errors | ||
#[error("json error")] | ||
JsonError(#[from] serde_json::Error), | ||
/// Convert cbor errors | ||
#[error("cbor error")] | ||
CborError(#[from] serde_cbor::Error), | ||
/// Convert bare errors | ||
#[error("bare error")] | ||
BareError(#[from] serde_bare::error::Error), | ||
/// Convert thread access errors | ||
#[error("thread access error")] | ||
ThreadAccessError(#[from] std::thread::AccessError), | ||
/// Generic errors to handle anything that implements the std::error::Error trait | ||
#[error("error: {0}")] | ||
Kind(Box<dyn std::error::Error>), | ||
appetrosyan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
impl From<String> for UrsaError { | ||
fn from(value: String) -> Self { | ||
Self::Kind(into_err(value)) | ||
} | ||
} | ||
|
||
impl From<&String> for UrsaError { | ||
fn from(value: &String) -> Self { | ||
Self::Kind(into_err(value.clone())) | ||
} | ||
} | ||
|
||
impl From<&str> for UrsaError { | ||
fn from(value: &str) -> Self { | ||
Self::Kind(new_err(value)) | ||
} | ||
} | ||
appetrosyan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// Results returned from ursa components | ||
pub type UrsaResult<T> = anyhow::Result<T, UrsaError>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,25 @@ | ||
//! This crate contains shared components used among the | ||
//! Ursa library | ||
|
||
#![deny( | ||
unused_variables, | ||
unused_imports, | ||
unused_import_braces, | ||
unused_parens, | ||
unused_lifetimes, | ||
unconditional_recursion, | ||
unused_extern_crates, | ||
trivial_casts, | ||
trivial_numeric_casts | ||
)] | ||
#![cfg_attr(docsrs, feature(doc_cfg))] | ||
|
||
mod error; | ||
|
||
pub use serde; | ||
pub use serde_bare; | ||
pub use serde_cbor; | ||
pub use serde_json; | ||
|
||
/// The errors generated by ursa components | ||
appetrosyan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub use error::*; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shared objects are a murky area. I do think that given that Ursa is a primarily going to be used as an rlib, this is the right call.