pub struct ValueCodecRegistration<D: 'static> { /* private fields */ }Expand description
One statically linked value-codec implementation.
A registration bundles the stable identifier used for lookup and duplicate
detection, a borrowed executable descriptor, and the link-time location the
registration was declared at. It is produced by
register_value_string_codec! or
register_value_bytes_codec! rather
than built by hand.
The registration macros validate codecs through the matching descriptor.
Encoder and decoder error types must implement Error + Send + Sync + 'static; codec and value types do not need those bounds.
§Type Parameters
D: Executable codec descriptor type;'staticlets the registry keep a borrowed&'static Dfor the whole program run.
§Examples
use qubit_codec::JsonStringValueCodec;
use qubit_codec::ValueCodecId;
use qubit_codec::ValueCodecRegistration;
use qubit_codec::ValueCodecRegistrationSource;
use qubit_codec::ValueStringCodecDescriptor;
use qubit_codec::ValueStringCodecRegistration;
static DESCRIPTOR: ValueStringCodecDescriptor =
ValueStringCodecDescriptor::of::<JsonStringValueCodec<u32>, u32>();
let registration: ValueStringCodecRegistration = ValueCodecRegistration::new(
ValueCodecId::new("example.u32"),
&DESCRIPTOR,
ValueCodecRegistrationSource::new(
"qubit-codec",
"doctest",
"src/value/value_codec_registration.rs",
1,
),
);
assert_eq!(registration.id().as_str(), "example.u32");Implementations§
Source§impl<D: 'static> ValueCodecRegistration<D>
impl<D: 'static> ValueCodecRegistration<D>
Sourcepub const fn id(&self) -> ValueCodecId
pub const fn id(&self) -> ValueCodecId
Returns the stable value-codec ID.
§Returns
Returns the identifier this registration was filed under.
Sourcepub const fn descriptor(&self) -> &'static D
pub const fn descriptor(&self) -> &'static D
Returns the executable descriptor.
§Returns
Returns the borrowed static descriptor, valid for the whole program run.
Sourcepub const fn source(&self) -> ValueCodecRegistrationSource
pub const fn source(&self) -> ValueCodecRegistrationSource
Returns the linked source location.
§Returns
Returns the link-time crate, module, file, and line of the declaration.