sqlite_diff_rs/wire/adapter.rs
1//! [`WireAdapter`]: single-method entry point for decoding one column
2//! payload into a [`Value`](crate::encoding::Value).
3//!
4//! The primary implementer is [`TypeMap`](super::TypeMap). Users who
5//! need per-column overrides (rare) implement `WireAdapter` on their
6//! own wrapper type.
7
8use super::error::DecodeError;
9use super::source::WireSource;
10use crate::encoding::Value;
11
12/// Decodes one per-column payload into a [`Value`].
13///
14/// Object-safe: `dyn WireAdapter<Src, S, B>` works. The primary
15/// implementation is [`TypeMap<Src, S, B>`](super::TypeMap), which
16/// dispatches on `Src::TypeKey` via a hashmap.
17pub trait WireAdapter<Src: WireSource, S, B> {
18 /// Decode one column payload.
19 ///
20 /// # Errors
21 ///
22 /// Returns [`DecodeError::NoDecoderForType`] when the underlying
23 /// registry has no decoder for the payload's type key, or the
24 /// specific decoder's own failure mode when it does.
25 fn decode(&self, payload: Src::Payload<'_>) -> Result<Value<S, B>, DecodeError>;
26}