UnicorndClient

Struct UnicorndClient 

Source
pub struct UnicorndClient { /* private fields */ }

Implementations§

Source§

impl UnicorndClient

Source

pub fn new(path: String) -> Option<Self>

Examples found in repository?
examples/rgb.rs (line 31)
30fn main() {
31    let mut u = UnicorndClient::new("/var/run/unicornd.socket".to_string()).unwrap();
32    u.set_brightness(128).unwrap();
33
34    let rgb = [
35        Pixel{r: 255, g:   0, b:   0},
36        Pixel{r:   0, g: 255, b:   0},
37        Pixel{r:   0, g:   0, b: 255}
38    ];
39
40    loop {
41        for p in rgb.iter() {
42            u.set_all_pixels(gen_solid(*p)).unwrap();
43            for x in 3..5 {
44                for y in 3..5 {
45                    u.set_pixel(Pos{x, y}, Pixel{r: 255, g: 255, b: 255}).unwrap();
46                }
47            }
48
49            u.show().unwrap();
50            sleep(Duration::new(1, 0));
51        }
52    }
53}
Source

pub fn set_brightness(&mut self, brightness: u8) -> Result<()>

Examples found in repository?
examples/rgb.rs (line 32)
30fn main() {
31    let mut u = UnicorndClient::new("/var/run/unicornd.socket".to_string()).unwrap();
32    u.set_brightness(128).unwrap();
33
34    let rgb = [
35        Pixel{r: 255, g:   0, b:   0},
36        Pixel{r:   0, g: 255, b:   0},
37        Pixel{r:   0, g:   0, b: 255}
38    ];
39
40    loop {
41        for p in rgb.iter() {
42            u.set_all_pixels(gen_solid(*p)).unwrap();
43            for x in 3..5 {
44                for y in 3..5 {
45                    u.set_pixel(Pos{x, y}, Pixel{r: 255, g: 255, b: 255}).unwrap();
46                }
47            }
48
49            u.show().unwrap();
50            sleep(Duration::new(1, 0));
51        }
52    }
53}
Source

pub fn set_pixel(&mut self, pos: Pos, col: Pixel) -> Result<()>

Examples found in repository?
examples/rgb.rs (line 45)
30fn main() {
31    let mut u = UnicorndClient::new("/var/run/unicornd.socket".to_string()).unwrap();
32    u.set_brightness(128).unwrap();
33
34    let rgb = [
35        Pixel{r: 255, g:   0, b:   0},
36        Pixel{r:   0, g: 255, b:   0},
37        Pixel{r:   0, g:   0, b: 255}
38    ];
39
40    loop {
41        for p in rgb.iter() {
42            u.set_all_pixels(gen_solid(*p)).unwrap();
43            for x in 3..5 {
44                for y in 3..5 {
45                    u.set_pixel(Pos{x, y}, Pixel{r: 255, g: 255, b: 255}).unwrap();
46                }
47            }
48
49            u.show().unwrap();
50            sleep(Duration::new(1, 0));
51        }
52    }
53}
Source

pub fn set_all_pixels(&mut self, pixels: [Pixel; 64]) -> Result<()>

Examples found in repository?
examples/rgb.rs (line 42)
30fn main() {
31    let mut u = UnicorndClient::new("/var/run/unicornd.socket".to_string()).unwrap();
32    u.set_brightness(128).unwrap();
33
34    let rgb = [
35        Pixel{r: 255, g:   0, b:   0},
36        Pixel{r:   0, g: 255, b:   0},
37        Pixel{r:   0, g:   0, b: 255}
38    ];
39
40    loop {
41        for p in rgb.iter() {
42            u.set_all_pixels(gen_solid(*p)).unwrap();
43            for x in 3..5 {
44                for y in 3..5 {
45                    u.set_pixel(Pos{x, y}, Pixel{r: 255, g: 255, b: 255}).unwrap();
46                }
47            }
48
49            u.show().unwrap();
50            sleep(Duration::new(1, 0));
51        }
52    }
53}
Source

pub fn show(&mut self) -> Result<()>

Examples found in repository?
examples/rgb.rs (line 49)
30fn main() {
31    let mut u = UnicorndClient::new("/var/run/unicornd.socket".to_string()).unwrap();
32    u.set_brightness(128).unwrap();
33
34    let rgb = [
35        Pixel{r: 255, g:   0, b:   0},
36        Pixel{r:   0, g: 255, b:   0},
37        Pixel{r:   0, g:   0, b: 255}
38    ];
39
40    loop {
41        for p in rgb.iter() {
42            u.set_all_pixels(gen_solid(*p)).unwrap();
43            for x in 3..5 {
44                for y in 3..5 {
45                    u.set_pixel(Pos{x, y}, Pixel{r: 255, g: 255, b: 255}).unwrap();
46                }
47            }
48
49            u.show().unwrap();
50            sleep(Duration::new(1, 0));
51        }
52    }
53}

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.