v0.1.0-pre.011

This commit is contained in:
2026-07-24 14:23:58 +02:00
parent 62bc0ffb44
commit 42e8a203ec
460 changed files with 12005 additions and 7020 deletions

View File

@@ -0,0 +1,42 @@
// file: kb-lib/tests/external_decoder_api.rs
// version: 1
//! Downstream-style compilation contract for externally implemented decoders.
struct ExternalDecoder;
impl kb_lib::DcApiProtocolDecoder for ExternalDecoder {
fn decoder_name(&self) -> &'static str {
return "external_decoder";
}
fn decoder_version(&self) -> &'static str {
return "1";
}
fn program_ids(&self) -> &'static [&'static str] {
return &[];
}
fn supports_observation(
&self,
_observation: &kb_lib::MdProgramObservation,
) -> kb_lib::DcApiDecoderSupport {
return kb_lib::DcApiDecoderSupport::No;
}
fn decode_observation(
&self,
_observation: &kb_lib::MdProgramObservation,
) -> kb_core::Result<std::vec::Vec<kb_lib::MdDecodedProtocolEvent>> {
return std::result::Result::Ok(std::vec::Vec::new());
}
}
#[test]
fn external_decoder_uses_only_the_public_kb_lib_contract() {
let decoder: &dyn kb_lib::DcApiProtocolDecoder = &ExternalDecoder;
assert_eq!(decoder.decoder_name(), "external_decoder");
assert_eq!(decoder.decoder_version(), "1");
assert!(decoder.program_ids().is_empty());
}