-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from cspr-rad/main
catch up with main
- Loading branch information
Showing
7 changed files
with
67 additions
and
8 deletions.
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,21 @@ | ||
name: extra-check | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
# https://github.com/cspr-rad/kairos/pull/61#issuecomment-2035637388 | ||
build-kairos-tx-without-std: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
- name: Build no_std version of `kairos-tx` | ||
run: cargo build -p kairos-tx --no-default-features |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,21 +1,48 @@ | ||
use core::fmt; | ||
|
||
use rasn::error::{DecodeError, EncodeError}; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
#[derive(Debug)] | ||
pub enum TxError { | ||
/// Errors related to encoding. | ||
#[error("encode error: {0}")] | ||
EncodeError(EncodeError), | ||
|
||
/// Errors related to decoding. | ||
#[error("decode error: {0}")] | ||
DecodeError(DecodeError), | ||
|
||
/// Constraint violation for a specific field. | ||
#[error("constraint violated for '{field}'")] | ||
ConstraintViolation { field: &'static str }, | ||
|
||
/// Signature verification failure. | ||
#[error("signature verification failed")] | ||
InvalidSignature, | ||
} | ||
|
||
impl fmt::Display for TxError { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
TxError::EncodeError(e) => write!(f, "encode error: {e}"), | ||
TxError::DecodeError(e) => write!(f, "decode error: {e}"), | ||
TxError::ConstraintViolation { field } => { | ||
write!(f, "constraint violated for '{field}'") | ||
} | ||
TxError::InvalidSignature => write!(f, "signature verification failed"), | ||
} | ||
} | ||
} | ||
|
||
#[cfg(not(feature = "std"))] | ||
mod error { | ||
use super::*; | ||
use core::fmt::{Debug, Display}; | ||
|
||
pub trait Error: Debug + Display { | ||
fn source(&self) -> Option<&(dyn Error + 'static)> { | ||
None | ||
} | ||
} | ||
|
||
impl Error for TxError {} | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
impl std::error::Error for TxError {} |
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
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,3 +1,6 @@ | ||
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)] | ||
extern crate alloc; | ||
|
||
pub mod asn; | ||
pub mod error; | ||
pub mod helpers; |