add derives, u8::from(&Brightness)
This commit is contained in:
		
							parent
							
								
									4f1ef8aafb
								
							
						
					
					
						commit
						eb42e0aba1
					
				
					 2 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
					@ -5,7 +5,7 @@ use bitvec::slice::IterMut;
 | 
				
			||||||
use crate::{BitVec, DataRef, Grid, PIXEL_HEIGHT, PIXEL_WIDTH};
 | 
					use crate::{BitVec, DataRef, Grid, PIXEL_HEIGHT, PIXEL_WIDTH};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// A grid of pixels stored in packed bytes.
 | 
					/// A grid of pixels stored in packed bytes.
 | 
				
			||||||
#[derive(Debug, Clone, PartialEq)]
 | 
					#[derive(Debug, Clone, PartialEq, Eq)]
 | 
				
			||||||
pub struct Bitmap {
 | 
					pub struct Bitmap {
 | 
				
			||||||
    width: usize,
 | 
					    width: usize,
 | 
				
			||||||
    height: usize,
 | 
					    height: usize,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,7 @@ use rand::{
 | 
				
			||||||
/// # let connection = Connection::open("127.0.0.1:2342").unwrap();
 | 
					/// # let connection = Connection::open("127.0.0.1:2342").unwrap();
 | 
				
			||||||
/// let result = connection.send(Command::Brightness(b));
 | 
					/// let result = connection.send(Command::Brightness(b));
 | 
				
			||||||
/// ```
 | 
					/// ```
 | 
				
			||||||
#[derive(Debug, Copy, Clone, PartialEq)]
 | 
					#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
 | 
				
			||||||
pub struct Brightness(u8);
 | 
					pub struct Brightness(u8);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// A grid containing brightness values.
 | 
					/// A grid containing brightness values.
 | 
				
			||||||
| 
						 | 
					@ -50,6 +50,12 @@ impl From<Brightness> for u8 {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl From<&Brightness> for u8 {
 | 
				
			||||||
 | 
					    fn from(brightness: &Brightness) -> Self {
 | 
				
			||||||
 | 
					        brightness.0
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl TryFrom<u8> for Brightness {
 | 
					impl TryFrom<u8> for Brightness {
 | 
				
			||||||
    type Error = u8;
 | 
					    type Error = u8;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue