pub trait TypedUuidKind:
Send
+ Sync
+ 'static {
// Required method
fn tag() -> TypedUuidTag;
// Provided method
fn alias() -> Option<&'static str> { ... }
}
Expand description
Represents marker types that can be used as a type parameter for TypedUuid
.
Generally, an implementation of this will be a zero-sized type that can never be constructed. An empty struct or enum works well for this.
§Implementations
If the schemars08
feature is enabled, and JsonSchema
is implemented for a kind T
, then
TypedUuid
<T>
will also implement JsonSchema
.
If you have a large number of UUID kinds, consider using
newtype-uuid-macros
which comes with several convenience features.
use newtype_uuid_macros::impl_typed_uuid_kinds;
// Invoke this macro with:
impl_typed_uuid_kinds! {
kinds = {
User = {},
Project = {},
// ...
},
}
See newtype-uuid-macros
for more information.
Required Methods§
Sourcefn tag() -> TypedUuidTag
fn tag() -> TypedUuidTag
Returns the corresponding tag for this kind.
The tag forms a runtime representation of this type.
The tag is required to be a static string.
Provided Methods§
Sourcefn alias() -> Option<&'static str>
fn alias() -> Option<&'static str>
Returns a string that corresponds to a type alias for TypedUuid<Self>
,
if one is defined.
The type alias must be defined in the same module as Self
. This
function is used by the schemars integration to refer to embed a
reference to that alias in the schema, if available.
This is usually defined by the newtype-uuid-macros
crate.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.