Struct pizarra::storage::Storage

source ·
pub struct Storage { /* private fields */ }
Expand description

This struct handles storage and fast retrieval of shapes.

Implementations§

source§

impl Storage

A storage struct that organizes shapes by their zoom level and allows for fast queries given a zoom and a bbox.

source

pub fn new() -> Storage

source

pub fn add(&mut self, shape: Box<dyn ShapeStored>) -> ShapeId

Adds a new shape to the storage

source

pub fn restore(&mut self, shape: Shape) -> ShapeId

Restores a deleted shape

source

pub fn remove(&mut self, id: ShapeId) -> Option<Shape>

Deletes a shape from this storage given its id if such id exists

source

pub fn remove_circle( &mut self, center: Vec2D<WorldUnit>, radius: WorldUnit ) -> impl Iterator<Item = Shape> + '_

Returns the id of a shape intersecting the circle described by center and radius, if any.

source

pub fn shape_count(&self) -> usize

Returns the number of shapes in this storage

source

pub fn shapes_by_index(&self) -> impl Iterator<Item = &dyn ShapeStored>

Returns the shapes stored in this storage ordered by their index. It is used for rendering the shapes in the order they where drawn. Creates an allocation.

source

pub fn draw_commands(&self, bbox: [Vec2D<WorldUnit>; 2]) -> Vec<DrawCommand>

gets all the draw commands necessary to paint the portion of the screen indicated by bbox. Commands are cached to improve the performance of continuously drawing on the same portion of the screen

source

pub fn get_bounds(&self) -> Option<[Vec2D<WorldUnit>; 2]>

Gets the bounding box that surrounds every shape drawn or returns None if there are no shapes

Trait Implementations§

source§

impl Debug for Storage

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Storage

source§

fn default() -> Storage

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Storage

§

impl !Send for Storage

§

impl !Sync for Storage

§

impl Unpin for Storage

§

impl !UnwindSafe for Storage

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.