Skip to main content

SourceType

Trait SourceType 

Source
pub trait SourceType:
    Send
    + Sync
    + 'static {
    type Style: StyleSourceType;
    type Data: TileKind;
    type Description: Send + Sync + 'static;

    const DESCRIBES_IN_BACKGROUND: bool = false;

    // Required method
    fn supply(source: &Source) -> Supply<Self::Data>;

    // Provided methods
    fn load(_source: &SourceData<Self::Style>) -> Load<Self::Description> { ... }
    fn describe(
        _options: &OptionsOf<Self>,
        _data: Option<Data>,
        respond: Respond<Described<Self::Description>>,
    ) { ... }
    fn describe_image(
        _options: &OptionsOf<Self>,
        _image: PremultipliedImage,
    ) -> Described<Self::Description> { ... }
    fn metadata_changed(
        _old: Option<&Self::Description>,
        _new: Option<&Self::Description>,
    ) -> bool { ... }
    fn attribution(_source: &SourceData<Self::Style>) -> Option<String> { ... }
    fn summary(_source: &SourceData<Self::Style>) -> SourceSummary { ... }
    fn offline(_source: &SourceData<Self::Style>) -> OfflineResources { ... }
    fn offline_tileset(
        _source: &SourceData<Self::Style>,
        _tilejson: &[u8],
    ) -> Result<Tileset, String> { ... }
    fn query_feature_extension(
        _source: &Source,
        _feature: &Feature,
        _extension: &str,
        _field: &str,
        _args: Option<&PropertyMap>,
    ) -> Result<FeatureExtensionValue, Error> { ... }
}
Expand description

A source type’s engine half: how its sources load, what they report and what they supply the renderer.

The hooks that take a source’s data take it as the style has it, a SourceData of the style half.

Provided Associated Constants§

Source

const DESCRIBES_IN_BACKGROUND: bool = false

Whether describe runs on the thread pool rather than on the map’s thread, for work such as indexing GeoJSON.

Required Associated Types§

Source

type Style: StyleSourceType

The style half: the type’s name, its kind of data and its options.

Source

type Data: TileKind

The kind of data its sources supply: the kind its style half’s layer_kind names, or the type doesn’t register.

Source

type Description: Send + Sync + 'static

What loading a source finds: a tileset, GeoJSON data, an image. The style holds it in SourceData::description.

Required Methods§

Source

fn supply(source: &Source) -> Supply<Self::Data>

What source, a source of the type, supplies the renderer, which makes it once, as the source joins the renderer’s style. A source that later takes its place with the same id and type, as a style reload makes, keeps the supply: its origin takes the new source in DataOrigin::update, and an image’s ImageOf reads it.

Provided Methods§

Source

fn load(_source: &SourceData<Self::Style>) -> Load<Self::Description>

How source’s description loads for its current options. The map asks again whenever SourceData::load grows.

Source

fn describe( _options: &OptionsOf<Self>, _data: Option<Data>, respond: Respond<Described<Self::Description>>, )

Turns data, the fetched resource of a Fetch::Source, into the description of a source of options, and answers through respond, at once or later. data is None for a response without content, and for a Load::Describe, which describes the options alone.

Source

fn describe_image( _options: &OptionsOf<Self>, _image: PremultipliedImage, ) -> Described<Self::Description>

Turns image, the decoded image of a Fetch::Image, into the description of a source of options.

Source

fn metadata_changed( _old: Option<&Self::Description>, _new: Option<&Self::Description>, ) -> bool

Whether new, a loaded description that replaces old, changes what the source says about itself, such as a tileset’s tiles and attribution, which the map reports as a change of the source.

Source

fn attribution(_source: &SourceData<Self::Style>) -> Option<String>

The source’s attribution, as its style or its description gives it.

Source

fn summary(_source: &SourceData<Self::Style>) -> SourceSummary

What the source reports about itself.

Source

fn offline(_source: &SourceData<Self::Style>) -> OfflineResources

What an offline download fetches for the source.

Source

fn offline_tileset( _source: &SourceData<Self::Style>, _tilejson: &[u8], ) -> Result<Tileset, String>

The tileset that an offline download takes the source’s tiles from, once the TileJSON that OfflineResources::TileJson named arrived.

§Errors

When tilejson doesn’t give the source a tileset.

Source

fn query_feature_extension( _source: &Source, _feature: &Feature, _extension: &str, _field: &str, _args: Option<&PropertyMap>, ) -> Result<FeatureExtensionValue, Error>

The field of the extension extension of feature, a feature that a query found in a tile of source, with args: such as a GeoJSON cluster’s leaves. A null value for an extension the type doesn’t have.

§Errors

When the source can’t answer, such as for a cluster it doesn’t have.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§