summaryrefslogblamecommitdiffstats
path: root/wgpu/src/widget/canvas/state.rs
blob: ab433dd1a06c81ace3af5b8c704e8f664d343ab3 (plain) (tree)
1
2
3
4
5
6
7
8
9
10

                                           



                                                                           



                                                  
                                          
     
                      
 

                                                                         





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

pub trait State<Message> {
    fn update(&mut self, _event: Event, _bounds: Size) -> Option<Message> {
        None
    }

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

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

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