Skip to main content

DataOrigin

Trait DataOrigin 

Source
pub trait DataOrigin: 'static {
    type Data: TileKind;
    type Tile: 'static;
    type Reply: Send + 'static;

    // Required methods
    fn update(&mut self, update: &mut OriginUpdate<'_, Self>) -> Option<Cover>;
    fn start(
        &mut self,
        cx: &mut LoadContext<'_, '_, Self>,
        copy: Option<WorldCopy<'_, Self::Tile>>,
    ) -> Self::Tile;
    fn receive(
        &mut self,
        tile: &mut Self::Tile,
        reply: Self::Reply,
        cx: &mut LoadContext<'_, '_, Self>,
    );

    // Provided methods
    fn set_necessity(
        &mut self,
        _tile: &mut Self::Tile,
        _previous: TileNecessity,
        _cx: &mut LoadContext<'_, '_, Self>,
    ) { ... }
    fn retry(
        &mut self,
        _tile: &mut Self::Tile,
        _cx: &mut LoadContext<'_, '_, Self>,
    ) { ... }
    fn failed(
        &mut self,
        _tile: &mut Self::Tile,
        _cx: &mut LoadContext<'_, '_, Self>,
    ) { ... }
}
Expand description

Where a source’s tiles get their data: what each tile has of the source’s data, and how it loads.

The tile hooks (start, receive, set_necessity, retry and failed) get the tile’s LoadContext, and all but start the origin’s state of the tile. The engine calls none of the hooks from within another.

Required Associated Types§

Source

type Data: TileKind

The kind of data its tiles take in.

Source

type Tile: 'static

What the origin keeps of each tile. The engine drops it as the tile goes, which lets go of what it holds, such as a request or a subscription.

Source

type Reply: Send + 'static

What a tile’s load gets back, which receive takes in.

Required Methods§

Source

fn update(&mut self, update: &mut OriginUpdate<'_, Self>) -> Option<Cover>

Takes in the source as the style has it now, before the cover’s update, in each of the renderer’s updates: the same version until the style changes it, so the origin tells a new version from the last it took in, and then clears or loads the tiles again as the source’s rules say. Returns what the tiles cover, or None while the source has nothing to make tiles from, in which case the engine leaves its tiles as they are and makes no new ones.

Source

fn start( &mut self, cx: &mut LoadContext<'_, '_, Self>, copy: Option<WorldCopy<'_, Self::Tile>>, ) -> Self::Tile

Starts a new tile and returns the origin’s state of it. The tile starts optional; the cover sets how much it needs it (set_necessity) as it retains it, after this. On a flat map, copy is the same tile in another world copy, whose contents the new tile already shows, and copy.take_into(cx) settles the tile on them, as its load’s answer. Otherwise the origin delivers the tile’s data at once, starts a load, or waits until the tile is needed.

Source

fn receive( &mut self, tile: &mut Self::Tile, reply: Self::Reply, cx: &mut LoadContext<'_, '_, Self>, )

Takes in reply, which came for the tile’s latest load.

Provided Methods§

Source

fn set_necessity( &mut self, _tile: &mut Self::Tile, _previous: TileNecessity, _cx: &mut LoadContext<'_, '_, Self>, )

The engine set how much the tile is needed, to cx.necessity() from previous, which may be the same: as each update’s cover retains the tile, and as it becomes optional.

Source

fn retry(&mut self, _tile: &mut Self::Tile, _cx: &mut LoadContext<'_, '_, Self>)

The engine retries the required tile’s failed loads, before each still image: it calls this for each required tile of the cover, failed or not, and the origin retries what of it failed. A tile that this begins a load of, or gives new data, loads anew; one that it leaves as it was stays as it was.

Source

fn failed( &mut self, _tile: &mut Self::Tile, _cx: &mut LoadContext<'_, '_, Self>, )

The engine couldn’t lay out or decode what the tile last took in, and reported the error; the tile keeps what it shows. Not called for the origin’s own LoadContext::fail or fail_retrying.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§