pub trait DataMarker {
    type Yokeable: for<'a> Yokeable<'a>;
Expand description

Trait marker for data structs. All types delivered by the data provider must be associated with something implementing this trait.

Structs implementing this trait are normally generated with the data_struct macro.

By convention, the non-standard Marker suffix is used by types implementing DataMarker.

In addition to a marker type implementing DataMarker, the following impls must also be present for the data struct:

  • impl<'a> Yokeable<'a> (required)
  • impl ZeroFrom<Self>

Also see KeyedDataMarker.


Manually implementing DataMarker for a custom type:

use icu_provider::prelude::*;
use icu_provider::yoke::*;
use icu_provider::zerofrom::*;
use std::borrow::Cow;
use std::rc::Rc;

#[derive(Yokeable, ZeroFrom)]
struct MyDataStruct<'data> {
    message: Cow<'data, str>,

struct MyDataStructMarker;

impl DataMarker for MyDataStructMarker {
    type Yokeable = MyDataStruct<'static>;

// We can now use MyDataStruct with DataProvider:
let s = MyDataStruct {
    message: Cow::Owned("Hello World".into()),
let payload = DataPayload::<MyDataStructMarker>::from_owned(s);
assert_eq!(payload.get().message, "Hello World");

Associated Types

A type that implements Yokeable. This should typically be the 'static version of a data struct.