diff --git a/crates/servicepoint/src/command.rs b/crates/servicepoint/src/command.rs index abe983c..8422971 100644 --- a/crates/servicepoint/src/command.rs +++ b/crates/servicepoint/src/command.rs @@ -76,12 +76,7 @@ pub enum Command { /// Show text on the screen. /// - /// The text is sent in the form of a 2D grid of characters. - /// - ///
- /// The library does not currently convert between UTF-8 and CP-437. - /// Because Rust expects UTF-8 strings, it might be necessary to only send ASCII for now. - ///
+ /// The text is sent in the form of a 2D grid of [CP-437] encoded characters. /// /// # Examples /// @@ -100,6 +95,7 @@ pub enum Command { /// let grid = Cp437Grid::load_ascii("Hello\nWorld", 5, false).unwrap(); /// connection.send(Command::Cp437Data(Origin::new(2, 2), grid)).unwrap(); /// ``` + /// [CP-437]: https://en.wikipedia.org/wiki/Code_page_437 Cp437Data(Origin, Cp437Grid), /// Overwrites a rectangular region of pixels. @@ -217,9 +213,8 @@ pub enum Command { BitmapLegacy, } -#[derive(Debug)] /// Err values for [Command::try_from]. -#[derive(PartialEq)] +#[derive(Debug, PartialEq)] pub enum TryFromPacketError { /// the contained command code does not correspond to a known command InvalidCommand(u16), diff --git a/crates/servicepoint/src/cp437.rs b/crates/servicepoint/src/cp437.rs index dc40627..d82d180 100644 --- a/crates/servicepoint/src/cp437.rs +++ b/crates/servicepoint/src/cp437.rs @@ -1,4 +1,7 @@ -use crate::cp437::Cp437LoadError::InvalidChar; +//! Conversion between UTF-8 and CP-437. +//! +//! Most of the functionality is only available with feature "cp437" enabled. + use crate::{Grid, PrimitiveGrid}; use std::collections::HashMap; @@ -10,9 +13,16 @@ pub type Cp437Grid = PrimitiveGrid; /// A grid containing UTF-8 characters. pub type CharGrid = PrimitiveGrid; +/// Errors that can occur when loading CP-437. #[derive(Debug)] pub enum Cp437LoadError { - InvalidChar { index: usize, char: char }, + /// Invalid character in input prevented loading + InvalidChar { + /// invalid character is at this position in input + index: usize, + /// the invalid character + char: char, + }, } impl Cp437Grid {