Skip to main content

solpipe_keysigner/
error.rs

1use libc::c_char;
2use thiserror::Error;
3use std::{error::Error as StdError, ffi::CString};
4
5#[derive(Debug, Error)]
6pub enum SolpipeError {
7    #[error("Unknown")]
8    Unknown,
9    #[error("Custom Error: {0}")]
10    Custom(String),
11    #[error("bad signing command")]
12    UnknownSigningCommand,
13    #[error("Signer not available")]
14    SignerNotAvailable,
15    #[error("failed to deserialize transaction: {0}")]
16    FailedToDeserializeTransaction(String),
17    #[error("bad blockhash")]
18    BadBlockHash,
19}
20
21
22#[no_mangle]
23pub extern "C" fn free_rust_string(ptr: *mut c_char) {
24    if !ptr.is_null() {
25        // Safety: Convert the pointer back to a CString and deallocate the memory.
26        unsafe { CString::from_raw(ptr) };
27    }
28}