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;
    const DESCRIBES_IN_WORLD: 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: &<Self::Style as StyleSourceType>::Options,
        _world: &WorldMapping,
        _data: Option<Arc<Vec<u8>>>,
        respond: Box<dyn FnOnce(Result<Option<Self::Description>, Error>) + Send>,
    ) { ... }
    fn describe_image(
        _options: &<Self::Style as StyleSourceType>::Options,
        _image: Image<Premultiplied>,
    ) -> Result<Option<Self::Description>, Error> { ... }
    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<&VecMap<String, Value>>,
    ) -> 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.

Source

const DESCRIBES_IN_WORLD: bool = false

Whether a description depends on the map’s world square, as GeoJSON tiled there does: the map then describes the source again when the style’s projection changes the world.

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: &<Self::Style as StyleSourceType>::Options, _world: &WorldMapping, _data: Option<Arc<Vec<u8>>>, respond: Box<dyn FnOnce(Result<Option<Self::Description>, Error>) + Send>, )

Turns data, the fetched resource of a Fetch::Source, into the description of a source of options on a map whose lng/lat maps to its world square as world maps it, 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: &<Self::Style as StyleSourceType>::Options, _image: Image<Premultiplied>, ) -> Result<Option<Self::Description>, Error>

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<&VecMap<String, Value>>, ) -> 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".

Implementations on Foreign Types§

Source§

impl SourceType for GeoJsonSource

Source§

fn load(source: &SourceData<GeoJsonSourceType>) -> Load<Arc<dyn GeoJSONData>>

The GeoJSON at the source’s URL, or the GeoJSON the style gives, which the source indexes as it describes it.

Source§

fn describe( options: &GeoJsonSourceOptions, world: &WorldMapping, data: Option<Arc<Vec<u8>>>, respond: Box<dyn FnOnce(Result<Option<Arc<dyn GeoJSONData>>, Error>) + Send>, )

Builds the fetched GeoJSON, or the GeoJSON the style gives, in the world square of world. Data that doesn’t build is logged and describes an empty source, so that its tiles don’t wait for data.

Source§

fn query_feature_extension( source: &Source, feature: &Feature, extension: &str, field: &str, args: Option<&VecMap<String, Value>>, ) -> Result<FeatureExtensionValue, Error>

The “supercluster” extension: a cluster feature’s “children”, “leaves” (args “limit”, default 10, and “offset”, default 0) or “expansion-zoom”. Anything else is a null value.

Source§

const DESCRIBES_IN_BACKGROUND: bool = true

Source§

const DESCRIBES_IN_WORLD: bool = true

Source§

type Style = GeoJsonSourceType

Source§

type Data = GeometryTiles

Source§

type Description = Arc<dyn GeoJSONData>

Source§

fn attribution(source: &SourceData<GeoJsonSourceType>) -> Option<String>

Source§

fn summary(source: &SourceData<GeoJsonSourceType>) -> SourceSummary

Source§

fn offline(source: &SourceData<GeoJsonSourceType>) -> OfflineResources

Source§

fn supply(_source: &Source) -> Supply<GeometryTiles>

Source§

impl SourceType for ImageSource

Source§

impl SourceType for TilesetSource<RasterDemKind>

Source§

impl SourceType for TilesetSource<RasterKind>

Source§

impl SourceType for TilesetSource<VectorKind>

Implementors§