v0.1.0-pre.011
This commit is contained in:
42
kb-lib/tests/external_decoder_api.rs
Normal file
42
kb-lib/tests/external_decoder_api.rs
Normal 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());
|
||||
}
|
||||
Reference in New Issue
Block a user