1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
/// # Pixelflut-RS /// A library providing a Pixelflut server to easily connect your display or whatever to it. /// /// The library enables you to use a working Pixelflut server with your Project. So you don't need /// to care about the details with the server and the parsing of the commands but concentrate on /// your visualisation project. In this library we call that a Grid. /// /// ## Grid /// /// A Grid can do 3 things /// 1. Return it's size /// 2. Draw a given Pixel on it /// 3. Fetch the current state of a Pixel on the Grid for a given Coordinate /// /// A really naive implementation could look like this: /// ```no_run /// # use pixelflut_rs::grid::{Grid, Size}; /// # use pixelflut_rs::pixel::{Pixel, Coordinate}; /// struct PrintlnGrid { /// size: Size, /// } /// /// impl Grid for PrintlnGrid { /// fn size(&self) -> Size { /// self.size.clone() /// } /// /// fn draw(&mut self, px: &Pixel) { /// println!("{}", px); /// } /// /// fn fetch(&self, p: Coordinate) -> Option<Pixel> { /// Some("PX 1024 768 ff0f00".parse().unwrap()) /// } /// } /// ``` /// /// ## Server /// To actually run your Grid implementation and attach the Pixelflut interface to it you just /// need to do the following: /// /// ```no_run /// # use pixelflut_rs::grid::Grid; /// # use pixelflut_rs::pixel::{Pixel, Coordinate}; /// use pixelflut_rs::server::Server; /// use pixelflut_rs::grid::Size; /// /// #[tokio::main] /// async fn main() -> Result<(), Box<dyn std::error::Error>>{ /// /// let grid = PrintlnGrid { /// size: Size::new(1024, 768), /// }; /// /// let server = Server::new("0.0.0.0".parse()?, 2342, grid); /// server.start().await /// } /// /// # struct PrintlnGrid { /// # size: Size, /// # } /// /// # impl Grid for PrintlnGrid { /// # fn size(&self) -> Size { /// # self.size.clone() /// # } /// /// # fn draw(&mut self, px: &Pixel) { /// # println!("{}", px); /// # } /// /// # fn fetch(&self, p: Coordinate) -> Option<Pixel> { /// # Some("PX 1024 768 ff0f00".parse().unwrap()) /// # } /// # } /// ``` pub mod grid; pub mod pixel; pub mod server;