summaryrefslogblamecommitdiffstats
path: root/wgpu/src/widget/canvas/state.rs
blob: 8388f94d3ef64ed39796ae8e5b1e63b2a7c43a7e (plain) (tree)



















                                                         
use crate::canvas::{Event, Geometry, Size};

pub trait State {
    fn update(&mut self, _event: Event, _bounds: Size) {}

    fn draw(&self, bounds: Size) -> Vec<Geometry>;
}

impl<T> State for &mut T
where
    T: State,
{
    fn update(&mut self, event: Event, bounds: Size) {
        T::update(self, event, bounds);
    }

    fn draw(&self, bounds: Size) -> Vec<Geometry> {
        T::draw(self, bounds)
    }
}