rename modules
This commit is contained in:
parent
c66e6db498
commit
d195f6100a
34 changed files with 110 additions and 110 deletions
|
|
@ -24,11 +24,11 @@ use servicepoint::*;
|
|||
|
||||
fn main() {
|
||||
// establish connection
|
||||
let connection = connection::Udp::open("172.23.42.29:2342")
|
||||
let connection = connections::Udp::open("172.23.42.29:2342")
|
||||
.expect("connection failed");
|
||||
|
||||
// clear screen content
|
||||
connection.send(command::Clear)
|
||||
connection.send(commands::Clear)
|
||||
.expect("send failed");
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -31,17 +31,17 @@ fn main() {
|
|||
cli.text.push("Hello, CCCB!".to_string());
|
||||
}
|
||||
|
||||
let connection = connection::Udp::open(&cli.destination)
|
||||
let connection = connections::Udp::open(&cli.destination)
|
||||
.expect("could not connect to display");
|
||||
|
||||
if cli.clear {
|
||||
connection
|
||||
.send(command::Clear)
|
||||
.send(commands::Clear)
|
||||
.expect("sending clear failed");
|
||||
}
|
||||
|
||||
let text = cli.text.join("\n");
|
||||
let command = command::Utf8Data {
|
||||
let command = commands::Utf8Data {
|
||||
origin: Origin::ZERO,
|
||||
grid: CharGrid::wrap_str(TILE_WIDTH, &text),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ struct Cli {
|
|||
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
let connection = connection::Udp::open(cli.destination)
|
||||
let connection = connections::Udp::open(cli.destination)
|
||||
.expect("could not connect to display");
|
||||
|
||||
let mut bitmap = Bitmap::max_sized();
|
||||
bitmap.fill(true);
|
||||
|
||||
let command = command::BitmapLinearWin {
|
||||
let command = commands::BitmapLinearWin {
|
||||
origin: Origin::ZERO,
|
||||
bitmap,
|
||||
compression: CompressionCode::default(),
|
||||
|
|
@ -31,7 +31,7 @@ fn main() {
|
|||
*byte = Brightness::try_from(level).unwrap();
|
||||
}
|
||||
|
||||
let command = command::CharBrightness {
|
||||
let command = commands::CharBrightness {
|
||||
origin: Origin::ZERO,
|
||||
grid: brightnesses,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ struct Cli {
|
|||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
|
||||
let connection = connection::Udp::open(&cli.destination)
|
||||
let connection = connections::Udp::open(&cli.destination)
|
||||
.expect("could not connect to display");
|
||||
let mut field = make_random_field(cli.probability);
|
||||
|
||||
loop {
|
||||
let command = command::BitmapLinearWin {
|
||||
let command = commands::BitmapLinearWin {
|
||||
origin: Origin::ZERO,
|
||||
bitmap: field.clone(),
|
||||
compression: CompressionCode::default(),
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ struct Cli {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let connection = connection::Udp::open(Cli::parse().destination)
|
||||
let connection = connections::Udp::open(Cli::parse().destination)
|
||||
.expect("could not connect to display");
|
||||
|
||||
let mut bitmap = Bitmap::max_sized();
|
||||
|
|
@ -22,7 +22,7 @@ fn main() {
|
|||
bitmap.set((y + x_offset) % PIXEL_WIDTH, y, true);
|
||||
}
|
||||
|
||||
let command = command::BitmapLinearWin {
|
||||
let command = commands::BitmapLinearWin {
|
||||
bitmap: bitmap.clone(),
|
||||
compression: CompressionCode::default(),
|
||||
origin: Origin::ZERO,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ struct Cli {
|
|||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
|
||||
let connection = connection::Udp::open(cli.destination)
|
||||
let connection = connections::Udp::open(cli.destination)
|
||||
.expect("could not connect to display");
|
||||
let wait_duration = Duration::from_millis(cli.wait_ms);
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ fn main() {
|
|||
let mut filled_grid = Bitmap::max_sized();
|
||||
filled_grid.fill(true);
|
||||
|
||||
let command = command::BitmapLinearWin {
|
||||
let command = commands::BitmapLinearWin {
|
||||
origin: Origin::ZERO,
|
||||
bitmap: filled_grid,
|
||||
compression: CompressionCode::default(),
|
||||
|
|
@ -59,7 +59,7 @@ fn main() {
|
|||
}
|
||||
|
||||
connection
|
||||
.send(command::CharBrightness { origin, grid: luma })
|
||||
.send(commands::CharBrightness { origin, grid: luma })
|
||||
.unwrap();
|
||||
std::thread::sleep(wait_duration);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
//! Example for how to use the WebSocket connection
|
||||
|
||||
use servicepoint::connection::Websocket;
|
||||
use servicepoint::connections::Websocket;
|
||||
use servicepoint::*;
|
||||
|
||||
fn main() {
|
||||
let uri = "ws://localhost:8080".parse().unwrap();
|
||||
let connection = Websocket::open(uri).unwrap();
|
||||
|
||||
connection.send(command::Clear).unwrap();
|
||||
connection.send(commands::Clear).unwrap();
|
||||
|
||||
let mut pixels = Bitmap::max_sized();
|
||||
pixels.fill(true);
|
||||
|
||||
let command = command::BitmapLinearWin {
|
||||
let command = commands::BitmapLinearWin {
|
||||
origin: Origin::ZERO,
|
||||
bitmap: pixels,
|
||||
compression: CompressionCode::default(),
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ fn main() {
|
|||
Duration::from_millis(cli.time / PIXEL_WIDTH as u64),
|
||||
);
|
||||
|
||||
let connection = connection::Udp::open(cli.destination)
|
||||
let connection = connections::Udp::open(cli.destination)
|
||||
.expect("could not connect to display");
|
||||
|
||||
let mut enabled_pixels = Bitmap::max_sized();
|
||||
|
|
@ -32,7 +32,7 @@ fn main() {
|
|||
enabled_pixels.set(x_offset % PIXEL_WIDTH, y, false);
|
||||
}
|
||||
|
||||
let command = command::BitmapLinearWin {
|
||||
let command = commands::BitmapLinearWin {
|
||||
origin: Origin::ZERO,
|
||||
bitmap: enabled_pixels.clone(),
|
||||
compression: CompressionCode::default(),
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ use rand::{
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use servicepoint::{Brightness, Command, Connection, connection};
|
||||
/// # use servicepoint::{Brightness, Command, Connection, connections};
|
||||
/// let b = Brightness::MAX;
|
||||
/// let val: u8 = b.into();
|
||||
///
|
||||
/// let b = Brightness::try_from(7).unwrap();
|
||||
/// # let connection = connection::Fake;
|
||||
/// # let connection = connections::Fake;
|
||||
/// let result = connection.send(b);
|
||||
/// ```
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ use crate::ByteGrid;
|
|||
/// grid.set(0, 0, Brightness::MIN);
|
||||
/// grid.set(1, 1, Brightness::MIN);
|
||||
///
|
||||
/// # let connection = connection::Fake;
|
||||
/// connection.send(command::CharBrightness {
|
||||
/// origin: Origin::new(3, 7),
|
||||
/// # let connection = connections::Fake;
|
||||
/// connection.send(commands::CharBrightness {
|
||||
/// origin: Origin::new(3, 7),
|
||||
/// grid
|
||||
/// }).unwrap()
|
||||
/// ```
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ use std::string::FromUtf8Error;
|
|||
/// let grid = CharGrid::from("You can\nload multiline\nstrings directly");
|
||||
/// assert_eq!(grid.get_row_str(1), Some("load multiline\0\0".to_string()));
|
||||
///
|
||||
/// # let connection = connection::Fake;
|
||||
/// let command = command::Utf8Data { origin: Origin::ZERO, grid };
|
||||
/// # let connection = connections::Fake;
|
||||
/// let command = commands::Utf8Data { origin: Origin::ZERO, grid };
|
||||
/// connection.send(command).unwrap()
|
||||
/// ```
|
||||
pub type CharGrid = ValueGrid<char>;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
command::check_command_code_only, command::TryFromPacketError,
|
||||
commands::check_command_code_only, commands::TryFromPacketError,
|
||||
command_code::CommandCode, Packet, TypedCommand,
|
||||
};
|
||||
use std::fmt::Debug;
|
||||
|
|
@ -12,10 +12,10 @@ use std::fmt::Debug;
|
|||
///
|
||||
/// ```rust
|
||||
/// # use servicepoint::*;
|
||||
/// # let connection = connection::Fake;
|
||||
/// # let connection = connections::Fake;
|
||||
/// // this sends a packet that does nothing
|
||||
/// # #[allow(deprecated)]
|
||||
/// connection.send(command::BitmapLegacy).unwrap();
|
||||
/// connection.send(commands::BitmapLegacy).unwrap();
|
||||
/// ```
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[deprecated]
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
command::TryFromPacketError, command_code::CommandCode,
|
||||
commands::TryFromPacketError, command_code::CommandCode,
|
||||
compression::into_decompressed, BitVec, CompressionCode, Header, Offset,
|
||||
Packet, TypedCommand,
|
||||
};
|
||||
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
/// The contained [BitVec] is always uncompressed.
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct BitmapLinear {
|
||||
/// where to start overwriting pixel data
|
||||
/// where to start overwriting pixel data
|
||||
pub offset: Offset,
|
||||
/// the pixels to send to the display as one long row
|
||||
pub bitvec: BitVec,
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
command::{BitmapLinear, TryFromPacketError},
|
||||
commands::{BitmapLinear, TryFromPacketError},
|
||||
command_code::CommandCode,
|
||||
BitVec, CompressionCode, Offset, Packet, TypedCommand,
|
||||
};
|
||||
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
/// The contained [BitVec] is always uncompressed.
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct BitmapLinearAnd {
|
||||
/// where to start overwriting pixel data
|
||||
/// where to start overwriting pixel data
|
||||
pub offset: Offset,
|
||||
/// the pixels to send to the display as one long row
|
||||
pub bitvec: BitVec,
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
command::{BitmapLinear, TryFromPacketError},
|
||||
commands::{BitmapLinear, TryFromPacketError},
|
||||
command_code::CommandCode,
|
||||
BitVec, CompressionCode, Offset, Packet, TypedCommand,
|
||||
};
|
||||
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
/// The contained [BitVec] is always uncompressed.
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct BitmapLinearOr {
|
||||
/// where to start overwriting pixel data
|
||||
/// where to start overwriting pixel data
|
||||
pub offset: Offset,
|
||||
/// the pixels to send to the display as one long row
|
||||
pub bitvec: BitVec,
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
command::TryFromPacketError, command_code::CommandCode,
|
||||
commands::TryFromPacketError, command_code::CommandCode,
|
||||
compression::into_compressed, compression::into_decompressed, Bitmap,
|
||||
CompressionCode, Grid, Header, Origin, Packet, Pixels, TypedCommand,
|
||||
TILE_SIZE,
|
||||
|
|
@ -13,14 +13,14 @@ use crate::{
|
|||
///
|
||||
/// ```rust
|
||||
/// # use servicepoint::*;
|
||||
/// # let connection = connection::Fake;
|
||||
/// # let connection = connections::Fake;
|
||||
/// #
|
||||
/// let mut bitmap = Bitmap::max_sized();
|
||||
/// // draw something to the pixels here
|
||||
/// # bitmap.set(2, 5, true);
|
||||
///
|
||||
/// // create command to send pixels
|
||||
/// let command = command::BitmapLinearWin {
|
||||
/// let command = commands::BitmapLinearWin {
|
||||
/// bitmap,
|
||||
/// origin: Origin::ZERO,
|
||||
/// compression: CompressionCode::Uncompressed
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
command::{BitmapLinear, TryFromPacketError},
|
||||
commands::{BitmapLinear, TryFromPacketError},
|
||||
command_code::CommandCode,
|
||||
BitVec, CompressionCode, Offset, Packet, TypedCommand,
|
||||
};
|
||||
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
/// The contained [BitVec] is always uncompressed.
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct BitmapLinearXor {
|
||||
/// where to start overwriting pixel data
|
||||
/// where to start overwriting pixel data
|
||||
pub offset: Offset,
|
||||
/// the pixels to send to the display as one long row
|
||||
pub bitvec: BitVec,
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
command::TryFromPacketError, command_code::CommandCode, BrightnessGrid,
|
||||
commands::TryFromPacketError, command_code::CommandCode, BrightnessGrid,
|
||||
ByteGrid, Header, Origin, Packet, Tiles, TypedCommand,
|
||||
};
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
command::check_command_code_only, command::TryFromPacketError,
|
||||
commands::check_command_code_only, commands::TryFromPacketError,
|
||||
command_code::CommandCode, Packet, TypedCommand,
|
||||
};
|
||||
use std::fmt::Debug;
|
||||
|
|
@ -9,9 +9,9 @@ use std::fmt::Debug;
|
|||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use servicepoint::{connection, Command, Connection, command};
|
||||
/// # let connection = connection::Fake;
|
||||
/// connection.send(command::Clear).unwrap();
|
||||
/// # use servicepoint::{connections, Command, Connection, commands};
|
||||
/// # let connection = connections::Fake;
|
||||
/// connection.send(commands::Clear).unwrap();
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
/// ```
|
||||
pub struct Clear;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
command::TryFromPacketError, command_code::CommandCode, Cp437Grid, Header,
|
||||
commands::TryFromPacketError, command_code::CommandCode, Cp437Grid, Header,
|
||||
Origin, Packet, Tiles, TypedCommand,
|
||||
};
|
||||
|
||||
|
|
@ -13,17 +13,17 @@ use crate::{
|
|||
///
|
||||
/// ```rust
|
||||
/// # use servicepoint::*;
|
||||
/// # let connection = connection::Fake;
|
||||
/// # let connection = connections::Fake;
|
||||
/// let grid = CharGrid::from("Hello,\nWorld!");
|
||||
/// let grid = Cp437Grid::from(&grid);
|
||||
/// connection.send(command::Cp437Data{ origin: Origin::ZERO, grid }).expect("send failed");
|
||||
/// connection.send(commands::Cp437Data{ origin: Origin::ZERO, grid }).expect("send failed");
|
||||
/// ```
|
||||
///
|
||||
/// ```rust
|
||||
/// # use servicepoint::*;
|
||||
/// # let connection = connection::Fake;
|
||||
/// # let connection = connections::Fake;
|
||||
/// let grid = Cp437Grid::load_ascii("Hello\nWorld", 5, false).unwrap();
|
||||
/// connection.send(command::Cp437Data{ origin: Origin::new(2, 2), grid }).unwrap();
|
||||
/// connection.send(commands::Cp437Data{ origin: Origin::new(2, 2), grid }).unwrap();
|
||||
/// ```
|
||||
/// [CP-437]: https://en.wikipedia.org/wiki/Code_page_437
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
command::check_command_code_only, command::TryFromPacketError,
|
||||
commands::check_command_code_only, commands::TryFromPacketError,
|
||||
command_code::CommandCode, Packet, TypedCommand,
|
||||
};
|
||||
use std::fmt::Debug;
|
||||
|
|
@ -12,8 +12,8 @@ use std::fmt::Debug;
|
|||
///
|
||||
/// ```rust
|
||||
/// # use servicepoint::*;
|
||||
/// # let connection = connection::Fake;
|
||||
/// connection.send(command::FadeOut).unwrap();
|
||||
/// # let connection = connections::Fake;
|
||||
/// connection.send(commands::FadeOut).unwrap();
|
||||
/// ```
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
/// ```
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
command::TryFromPacketError, command_code::CommandCode, Brightness, Header,
|
||||
commands::TryFromPacketError, command_code::CommandCode, Brightness, Header,
|
||||
Packet, TypedCommand,
|
||||
};
|
||||
|
||||
|
|
@ -9,8 +9,8 @@ use crate::{
|
|||
///
|
||||
/// ```rust
|
||||
/// # use servicepoint::*;
|
||||
/// # let connection = connection::Fake;
|
||||
/// let command = command::GlobalBrightness { brightness: Brightness::MAX };
|
||||
/// # let connection = connections::Fake;
|
||||
/// let command = commands::GlobalBrightness { brightness: Brightness::MAX };
|
||||
/// connection.send(command).unwrap();
|
||||
/// ```
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
command::check_command_code_only, command::TryFromPacketError,
|
||||
commands::check_command_code_only, commands::TryFromPacketError,
|
||||
command_code::CommandCode, Packet, TypedCommand,
|
||||
};
|
||||
use std::fmt::Debug;
|
||||
|
|
@ -12,8 +12,8 @@ use std::fmt::Debug;
|
|||
///
|
||||
/// ```rust
|
||||
/// # use servicepoint::*;
|
||||
/// # let connection = connection::Fake;
|
||||
/// connection.send(command::HardReset).unwrap();
|
||||
/// # let connection = connections::Fake;
|
||||
/// connection.send(commands::HardReset).unwrap();
|
||||
/// ```
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
/// ```
|
||||
|
|
@ -31,19 +31,19 @@
|
|||
//! use servicepoint::*;
|
||||
//!
|
||||
//! // create command
|
||||
//! let command = command::GlobalBrightness{ brightness: Brightness::MAX };
|
||||
//! let command = commands::GlobalBrightness{ brightness: Brightness::MAX };
|
||||
//!
|
||||
//! // turn command into Packet
|
||||
//! let packet: Packet = command.clone().into();
|
||||
//!
|
||||
//! // read command from packet
|
||||
//! let round_tripped = command::TypedCommand::try_from(packet).unwrap();
|
||||
//! let round_tripped = commands::TypedCommand::try_from(packet).unwrap();
|
||||
//!
|
||||
//! // round tripping produces exact copy
|
||||
//! assert_eq!(round_tripped, TypedCommand::from(command.clone()));
|
||||
//!
|
||||
//! // send command
|
||||
//! # let connection = connection::Fake;
|
||||
//! # let connection = connections::Fake;
|
||||
//! connection.send(command).unwrap();
|
||||
//! ```
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ pub(self) fn check_command_code_only(packet: Packet, code: CommandCode) -> Optio
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::command::{BitmapLinear, BitmapLinearWin, BitmapLinearXor, CharBrightness, GlobalBrightness, TryFromPacketError};
|
||||
use crate::commands::{BitmapLinear, BitmapLinearWin, BitmapLinearXor, CharBrightness, GlobalBrightness, TryFromPacketError};
|
||||
use crate::command_code::CommandCode;
|
||||
use crate::*;
|
||||
|
||||
|
|
@ -304,17 +304,17 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn round_trip_clear() {
|
||||
round_trip(TypedCommand::Clear(command::Clear));
|
||||
round_trip(TypedCommand::Clear(commands::Clear));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn round_trip_hard_reset() {
|
||||
round_trip(TypedCommand::HardReset(command::HardReset));
|
||||
round_trip(TypedCommand::HardReset(commands::HardReset));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn round_trip_fade_out() {
|
||||
round_trip(TypedCommand::FadeOut(command::FadeOut));
|
||||
round_trip(TypedCommand::FadeOut(commands::FadeOut));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -327,7 +327,7 @@ mod tests {
|
|||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn round_trip_bitmap_legacy() {
|
||||
round_trip(TypedCommand::BitmapLegacy(command::BitmapLegacy));
|
||||
round_trip(TypedCommand::BitmapLegacy(commands::BitmapLegacy));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -340,7 +340,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn round_trip_cp437_data() {
|
||||
round_trip(TypedCommand::Cp437Data(command::Cp437Data {
|
||||
round_trip(TypedCommand::Cp437Data(commands::Cp437Data {
|
||||
origin: Origin::new(5, 2),
|
||||
grid: Cp437Grid::new(7, 5),
|
||||
}));
|
||||
|
|
@ -348,7 +348,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn round_trip_utf8_data() {
|
||||
round_trip(TypedCommand::Utf8Data(command::Utf8Data {
|
||||
round_trip(TypedCommand::Utf8Data(commands::Utf8Data {
|
||||
origin: Origin::new(5, 2),
|
||||
grid: CharGrid::new(7, 5),
|
||||
}));
|
||||
|
|
@ -363,13 +363,13 @@ mod tests {
|
|||
compression,
|
||||
}));
|
||||
round_trip(TypedCommand::BitmapLinearAnd(
|
||||
command::BitmapLinearAnd {
|
||||
commands::BitmapLinearAnd {
|
||||
offset: 23,
|
||||
bitvec: BitVec::repeat(false, 40),
|
||||
compression,
|
||||
},
|
||||
));
|
||||
round_trip(TypedCommand::BitmapLinearOr(command::BitmapLinearOr {
|
||||
round_trip(TypedCommand::BitmapLinearOr(commands::BitmapLinearOr {
|
||||
offset: 23,
|
||||
bitvec: BitVec::repeat(false, 40),
|
||||
compression,
|
||||
|
|
@ -504,7 +504,7 @@ mod tests {
|
|||
#[test]
|
||||
fn error_decompression_failed_win() {
|
||||
for compression in all_compressions().iter().copied() {
|
||||
let p: Packet = command::BitmapLinearWin {
|
||||
let p: Packet = commands::BitmapLinearWin {
|
||||
origin: Origin::new(16, 8),
|
||||
bitmap: Bitmap::new(8, 8),
|
||||
compression,
|
||||
|
|
@ -534,7 +534,7 @@ mod tests {
|
|||
#[test]
|
||||
fn error_decompression_failed_and() {
|
||||
for compression in all_compressions().iter().copied() {
|
||||
let p: Packet = command::BitmapLinearAnd {
|
||||
let p: Packet = commands::BitmapLinearAnd {
|
||||
offset: 0,
|
||||
bitvec: BitVec::repeat(false, 8),
|
||||
compression,
|
||||
|
|
@ -594,7 +594,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn error_reserved_used() {
|
||||
let Packet { header, payload } = command::BitmapLinear {
|
||||
let Packet { header, payload } = commands::BitmapLinear {
|
||||
offset: 0,
|
||||
bitvec: BitVec::repeat(false, 8),
|
||||
compression: CompressionCode::Uncompressed,
|
||||
|
|
@ -625,7 +625,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn error_invalid_compression() {
|
||||
let Packet { header, payload } = command::BitmapLinear {
|
||||
let Packet { header, payload } = commands::BitmapLinear {
|
||||
offset: 0,
|
||||
bitvec: BitVec::repeat(false, 8),
|
||||
compression: CompressionCode::Uncompressed,
|
||||
|
|
@ -656,7 +656,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn error_unexpected_size() {
|
||||
let Packet { header, payload } = command::BitmapLinear {
|
||||
let Packet { header, payload } = commands::BitmapLinear {
|
||||
offset: 0,
|
||||
bitvec: BitVec::repeat(false, 8),
|
||||
compression: CompressionCode::Uncompressed,
|
||||
|
|
@ -699,7 +699,7 @@ mod tests {
|
|||
#[test]
|
||||
fn packet_into_char_brightness_invalid() {
|
||||
let grid = BrightnessGrid::new(2, 2);
|
||||
let command = command::CharBrightness{origin: Origin::ZERO, grid};
|
||||
let command = commands::CharBrightness{origin: Origin::ZERO, grid};
|
||||
let mut packet: Packet = command.into();
|
||||
let slot = packet.payload.get_mut(1).unwrap();
|
||||
*slot = 23;
|
||||
|
|
@ -711,7 +711,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn packet_into_brightness_invalid() {
|
||||
let mut packet: Packet = command::GlobalBrightness{brightness: Brightness::MAX}.into();
|
||||
let mut packet: Packet = commands::GlobalBrightness{brightness: Brightness::MAX}.into();
|
||||
let slot = packet.payload.get_mut(0).unwrap();
|
||||
*slot = 42;
|
||||
assert_eq!(
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
command::TryFromPacketError, command_code::CommandCode, CharGrid, Header,
|
||||
commands::TryFromPacketError, command_code::CommandCode, CharGrid, Header,
|
||||
Origin, Packet, Tiles, TypedCommand,
|
||||
};
|
||||
|
||||
|
|
@ -11,9 +11,9 @@ use crate::{
|
|||
///
|
||||
/// ```rust
|
||||
/// # use servicepoint::*;
|
||||
/// # let connection = connection::Fake;
|
||||
/// # let connection = connections::Fake;
|
||||
/// let grid = CharGrid::from("Hello,\nWorld!");
|
||||
/// connection.send(command::Utf8Data { origin: Origin::ZERO, grid }).expect("send failed");
|
||||
/// connection.send(commands::Utf8Data { origin: Origin::ZERO, grid }).expect("send failed");
|
||||
/// ```
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Utf8Data {
|
||||
|
|
@ -6,17 +6,17 @@
|
|||
/// # use servicepoint::*;
|
||||
/// // create command without payload compression
|
||||
/// # let pixels = Bitmap::max_sized();
|
||||
/// _ = command::BitmapLinearWin {
|
||||
/// origin: Origin::ZERO,
|
||||
/// bitmap: pixels,
|
||||
/// _ = commands::BitmapLinearWin {
|
||||
/// origin: Origin::ZERO,
|
||||
/// bitmap: pixels,
|
||||
/// compression: CompressionCode::Uncompressed
|
||||
/// };
|
||||
///
|
||||
/// // create command with payload compressed with lzma and appropriate header flags
|
||||
/// # let pixels = Bitmap::max_sized();
|
||||
/// _ = command::BitmapLinearWin {
|
||||
/// _ = commands::BitmapLinearWin {
|
||||
/// origin: Origin::ZERO,
|
||||
/// bitmap: pixels,
|
||||
/// bitmap: pixels,
|
||||
/// compression: CompressionCode::Lzma
|
||||
/// };
|
||||
/// ```
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ pub use websocket::*;
|
|||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// use servicepoint::{command, connection, Connection};
|
||||
/// let connection = connection::Udp::open("127.0.0.1:2342")
|
||||
/// use servicepoint::{commands, connections, Connection};
|
||||
/// let connection = connections::Udp::open("127.0.0.1:2342")
|
||||
/// .expect("connection failed");
|
||||
/// connection.send(command::Clear)
|
||||
/// connection.send(commands::Clear)
|
||||
/// .expect("send failed");
|
||||
/// ```
|
||||
pub trait Connection: Debug {
|
||||
|
|
@ -43,10 +43,10 @@ pub trait Connection: Debug {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use servicepoint::connection::Connection;
|
||||
/// let connection = servicepoint::connection::Fake;
|
||||
/// # use servicepoint::connections::Connection;
|
||||
/// let connection = servicepoint::connections::Fake;
|
||||
/// // turn off all pixels on display
|
||||
/// connection.send(servicepoint::command::Clear)
|
||||
/// connection.send(servicepoint::commands::Clear)
|
||||
/// .expect("send failed");
|
||||
/// ```
|
||||
fn send(&self, packet: impl Into<Packet>) -> Result<(), Self::Error>;
|
||||
|
|
@ -25,7 +25,7 @@ impl Udp {
|
|||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// let connection = servicepoint::connection::Udp::open("127.0.0.1:2342")
|
||||
/// let connection = servicepoint::connections::Udp::open("127.0.0.1:2342")
|
||||
/// .expect("connection failed");
|
||||
/// ```
|
||||
pub fn open(
|
||||
|
|
@ -40,7 +40,7 @@ impl Websocket {
|
|||
/// use tungstenite::http::Uri;
|
||||
/// use servicepoint::{
|
||||
/// Command,
|
||||
/// connection::{Websocket as WebsocketConnection, Connection}
|
||||
/// connections::{Websocket as WebsocketConnection, Connection}
|
||||
/// };
|
||||
/// let uri = "ws://localhost:8080".parse().unwrap();
|
||||
/// let mut connection = WebsocketConnection::open(uri)
|
||||
|
|
@ -53,14 +53,14 @@ pub const PIXEL_COUNT: usize = PIXEL_WIDTH * PIXEL_HEIGHT;
|
|||
/// ```rust
|
||||
/// # use std::time::Instant;
|
||||
/// # use servicepoint::*;
|
||||
/// # let connection = connection::Fake;
|
||||
/// # let connection = connections::Fake;
|
||||
/// # let pixels = Bitmap::max_sized();
|
||||
/// loop {
|
||||
/// let start = Instant::now();
|
||||
///
|
||||
/// // Change pixels here
|
||||
///
|
||||
/// connection.send(command::BitmapLinearWin {
|
||||
/// connection.send(commands::BitmapLinearWin {
|
||||
/// origin: Origin::new(0,0),
|
||||
/// bitmap: pixels,
|
||||
/// compression: CompressionCode::default()
|
||||
|
|
|
|||
20
src/lib.rs
20
src/lib.rs
|
|
@ -12,11 +12,11 @@
|
|||
//! use servicepoint::*;
|
||||
//!
|
||||
//! // establish a connection
|
||||
//! let connection = connection::Udp::open("127.0.0.1:2342")
|
||||
//! let connection = connections::Udp::open("127.0.0.1:2342")
|
||||
//! .expect("connection failed");
|
||||
//!
|
||||
//! // turn off all pixels on display
|
||||
//! connection.send(command::Clear)
|
||||
//! connection.send(commands::Clear)
|
||||
//! .expect("send failed");
|
||||
//! ```
|
||||
//!
|
||||
|
|
@ -24,13 +24,13 @@
|
|||
//!
|
||||
//! ```rust
|
||||
//! # use servicepoint::*;
|
||||
//! # let connection = connection::Udp::open("127.0.0.1:2342").expect("connection failed");
|
||||
//! # let connection = connections::Udp::open("127.0.0.1:2342").expect("connection failed");
|
||||
//! // turn on all pixels in a grid
|
||||
//! let mut pixels = Bitmap::max_sized();
|
||||
//! pixels.fill(true);
|
||||
//!
|
||||
//! // create command to send pixels
|
||||
//! let command = command::BitmapLinearWin {
|
||||
//! let command = commands::BitmapLinearWin {
|
||||
//! origin: Origin::ZERO,
|
||||
//! bitmap: pixels,
|
||||
//! compression: CompressionCode::default()
|
||||
|
|
@ -44,13 +44,13 @@
|
|||
//!
|
||||
//! ```rust
|
||||
//! # use servicepoint::*;
|
||||
//! # let connection = connection::Udp::open("127.0.0.1:2342").expect("connection failed");
|
||||
//! # let connection = connections::Udp::open("127.0.0.1:2342").expect("connection failed");
|
||||
//! // create a text grid
|
||||
//! let mut grid = CharGrid::from("Hello\nCCCB?");
|
||||
//! // modify the grid
|
||||
//! grid.set(grid.width() - 1, 1, '!');
|
||||
//! // create the command to send the data
|
||||
//! let command = command::Utf8Data { origin: Origin::ZERO, grid };
|
||||
//! let command = commands::Utf8Data { origin: Origin::ZERO, grid };
|
||||
//! // send command to display
|
||||
//! connection.send(command).expect("send failed");
|
||||
//! ```
|
||||
|
|
@ -61,9 +61,9 @@ pub use crate::brightness::Brightness;
|
|||
pub use crate::brightness_grid::BrightnessGrid;
|
||||
pub use crate::byte_grid::ByteGrid;
|
||||
pub use crate::char_grid::CharGrid;
|
||||
pub use crate::command::{Command, TypedCommand};
|
||||
pub use crate::commands::{Command, TypedCommand};
|
||||
pub use crate::compression_code::CompressionCode;
|
||||
pub use crate::connection::Connection;
|
||||
pub use crate::connections::Connection;
|
||||
pub use crate::constants::*;
|
||||
pub use crate::cp437_grid::Cp437Grid;
|
||||
pub use crate::data_ref::DataRef;
|
||||
|
|
@ -80,11 +80,11 @@ mod brightness;
|
|||
mod brightness_grid;
|
||||
mod byte_grid;
|
||||
mod char_grid;
|
||||
pub mod command;
|
||||
pub mod commands;
|
||||
mod command_code;
|
||||
mod compression;
|
||||
mod compression_code;
|
||||
pub mod connection;
|
||||
pub mod connections;
|
||||
mod constants;
|
||||
mod cp437_grid;
|
||||
mod data_ref;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
//!
|
||||
//! ```rust
|
||||
//! use servicepoint::{Command, Packet, TypedCommand};
|
||||
//! # let command = servicepoint::command::Clear;
|
||||
//! # let command = servicepoint::commands::Clear;
|
||||
//! let packet: Packet = command.into();
|
||||
//! let command = TypedCommand::try_from(packet).expect("could not read command from packet");
|
||||
//! ```
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
//!
|
||||
//! ```rust
|
||||
//! use servicepoint::{Command, Packet};
|
||||
//! # let command = servicepoint::command::Clear;
|
||||
//! # let command = servicepoint::commands::Clear;
|
||||
//! # let packet: Packet = command.into();
|
||||
//! let bytes: Vec<u8> = packet.into();
|
||||
//! let packet = Packet::try_from(bytes).expect("could not read packet from bytes");
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ impl<T: Value> ValueGrid<T> {
|
|||
/// let mut grid: ByteGrid = ByteGrid::new(TILE_WIDTH, TILE_HEIGHT);
|
||||
/// foo(&mut grid);
|
||||
/// let grid: BrightnessGrid = grid.map(Brightness::saturating_from);
|
||||
/// let command = command::CharBrightness { origin: Origin::ZERO, grid };
|
||||
/// let command = commands::CharBrightness { origin: Origin::ZERO, grid };
|
||||
/// ```
|
||||
/// [Brightness]: [crate::Brightness]
|
||||
/// [Command]: [crate::Command]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue