use thiserror::Error;
use super::types::DasAsset;
#[derive(Debug, Error)]
pub enum DecoderError {
#[error("decoder `{decoder}` failed on {context}: {source}")]
DecodeFailed {
decoder: &'static str,
context: String,
#[source]
source: std::io::Error,
},
#[error("decoder `{decoder}`: {reason}")]
Invariant {
decoder: &'static str,
reason: &'static str,
},
}
pub trait AccountDecoder: Send + Sync {
fn program_id(&self) -> &str;
fn name(&self) -> &str;
fn decode(&self, pubkey: &str, data: &[u8]) -> Result<Option<DasAsset>, DecoderError>;
}