[][src]Trait icu_provider::prelude::DataProvider

pub trait DataProvider<'d> {
    fn load<'a>(&'a self, req: &DataRequest) -> Result<DataResponse<'d>, Error>;
}

An abstract data provider that takes a request object and returns a response with a payload. Lifetimes:

  • 'a = lifetime of the DataProvider object
  • 'd = lifetime of the borrowed payload Note: 'd and 'a can be the same, but they do not need to be. For example, 'd = 'static if:
  1. The provider always returns data that lives in static memory
  2. The provider always returns owned data, not borrowed data

Required methods

fn load<'a>(&'a self, req: &DataRequest) -> Result<DataResponse<'d>, Error>

Query the provider for data. Returns Ok if the request successfully loaded data. If data failed to load, returns an Error with more information.

Loading content...

Implementations

impl<'d> dyn DataProvider<'d> + 'd[src]

pub fn load_graceful(
    &self,
    req: &DataRequest
) -> Result<Option<DataResponse<'d>>, Error>
[src]

Query the provider for data. Returns Ok(Some) if the request successfully loaded data. If data failed to load due to the provider not supporting the requested category or data key, returns Ok(None). Otherwise, returns an Error.

Implementors

Loading content...