Skip to main content

qubit_codec/transcode/
transcode_converter.rs

1// =============================================================================
2//    Copyright (c) 2026 Haixing Hu.
3//
4//    SPDX-License-Identifier: Apache-2.0
5//
6//    Licensed under the Apache License, Version 2.0.
7// =============================================================================
8//! Semantic marker trait for buffered converters.
9
10use super::TranscodeConvertError;
11use super::Transcoder;
12
13/// Converts encoded units of one representation into encoded units of another.
14///
15/// `TranscodeConverter` refines [`Transcoder`] for implementations whose
16/// input and output are both encoded unit streams. Any intermediate logical
17/// values are implementation details of the concrete converter.
18///
19/// The trait adds no methods. It exists to make generic bounds distinguish
20/// unit-to-unit conversion from value-to-unit encoding and unit-to-value
21/// decoding.
22///
23/// # Examples
24///
25/// ```
26/// use qubit_codec::TranscodeConverter;
27///
28/// fn accepts_converter<C: TranscodeConverter>(converter: &C) {
29///     let _ = converter;
30/// }
31/// ```
32pub trait TranscodeConverter:
33    Transcoder<Error = TranscodeConvertError<Self::DecodeError, Self::EncodeError, Self::Value>>
34{
35    /// Domain error type produced by source decoding.
36    type DecodeError;
37
38    /// Domain error type produced by target encoding.
39    type EncodeError;
40
41    /// Intermediate logical value type converted between source and target.
42    type Value;
43}