pub trait AnyProvider {
    fn load_any(
        key: DataKey,
        req: DataRequest<'_>
    ) -> Result<AnyResponse, DataError>; }
Expand description

An object-safe data provider that returns data structs cast to dyn Any trait objects.


use icu_provider::hello_world::*;
use icu_provider::prelude::*;
use std::borrow::Cow;

let any_response = HelloWorldProvider
        DataRequest {
            locale: &icu_locid::locale!("de").into(),
            metadata: Default::default(),
    .expect("Load should succeed");

// Downcast to something useful
let response: DataResponse<HelloWorldV1Marker> =
    any_response.downcast().expect("Types match");

let payload = response.take_payload().expect("Data should be present");

assert_eq!(payload.get().message, "Hallo Welt");

Required methods

Loads an AnyPayload according to the key and request.

Implementations on Foreign Types