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.
§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.
Trait Implementations§
Source§impl<D: Clone + 'static> Clone for ValueCodecRegistration<D>
impl<D: Clone + 'static> Clone for ValueCodecRegistration<D>
impl<D: Copy + 'static> Copy for ValueCodecRegistration<D>
Auto Trait Implementations§
impl<D> Freeze for ValueCodecRegistration<D>where
&'static D: Freeze,
impl<D> RefUnwindSafe for ValueCodecRegistration<D>where
&'static D: RefUnwindSafe,
impl<D> Send for ValueCodecRegistration<D>where
&'static D: Send,
impl<D> Sync for ValueCodecRegistration<D>where
&'static D: Sync,
impl<D> Unpin for ValueCodecRegistration<D>where
&'static D: Unpin,
impl<D> UnsafeUnpin for ValueCodecRegistration<D>where
&'static D: UnsafeUnpin,
impl<D> UnwindSafe for ValueCodecRegistration<D>where
&'static D: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more