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§
Sourceconst DESCRIBES_IN_BACKGROUND: bool = false
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.
Sourceconst DESCRIBES_IN_WORLD: bool = false
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§
Sourcetype Style: StyleSourceType
type Style: StyleSourceType
The style half: the type’s name, its kind of data and its options.
Sourcetype Data: TileKind
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.
Sourcetype Description: Send + Sync + 'static
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§
Sourcefn supply(source: &Source) -> Supply<Self::Data>
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§
Sourcefn load(_source: &SourceData<Self::Style>) -> Load<Self::Description>
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.
Sourcefn 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( _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.
Sourcefn describe_image(
_options: &<Self::Style as StyleSourceType>::Options,
_image: Image<Premultiplied>,
) -> Result<Option<Self::Description>, Error>
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.
Sourcefn metadata_changed(
_old: Option<&Self::Description>,
_new: Option<&Self::Description>,
) -> bool
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.
Sourcefn attribution(_source: &SourceData<Self::Style>) -> Option<String>
fn attribution(_source: &SourceData<Self::Style>) -> Option<String>
The source’s attribution, as its style or its description gives it.
Sourcefn summary(_source: &SourceData<Self::Style>) -> SourceSummary
fn summary(_source: &SourceData<Self::Style>) -> SourceSummary
What the source reports about itself.
Sourcefn offline(_source: &SourceData<Self::Style>) -> OfflineResources
fn offline(_source: &SourceData<Self::Style>) -> OfflineResources
What an offline download fetches for the source.
Sourcefn offline_tileset(
_source: &SourceData<Self::Style>,
_tilejson: &[u8],
) -> Result<Tileset, String>
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.
Sourcefn query_feature_extension(
_source: &Source,
_feature: &Feature,
_extension: &str,
_field: &str,
_args: Option<&VecMap<String, Value>>,
) -> Result<FeatureExtensionValue, Error>
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
impl SourceType for GeoJsonSource
Source§fn load(source: &SourceData<GeoJsonSourceType>) -> Load<Arc<dyn GeoJSONData>>
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>,
)
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>
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.
const DESCRIBES_IN_BACKGROUND: bool = true
const DESCRIBES_IN_WORLD: bool = true
type Style = GeoJsonSourceType
type Data = GeometryTiles
type Description = Arc<dyn GeoJSONData>
fn attribution(source: &SourceData<GeoJsonSourceType>) -> Option<String>
fn summary(source: &SourceData<GeoJsonSourceType>) -> SourceSummary
fn offline(source: &SourceData<GeoJsonSourceType>) -> OfflineResources
fn supply(_source: &Source) -> Supply<GeometryTiles>
Source§impl SourceType for ImageSource
impl SourceType for ImageSource
Source§fn load(source: &SourceData<ImageSourceType>) -> Load<Image<Premultiplied>>
fn load(source: &SourceData<ImageSourceType>) -> Load<Image<Premultiplied>>
The image at the source’s URL, if it has one.