mirror of
https://github.com/cccb/servicepoint.git
synced 2025-01-18 10:00:14 +01:00
improve docs
This commit is contained in:
parent
f7fddda8f1
commit
ce946c2fb8
|
@ -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.
|
||||
///
|
||||
/// <div class="warning">
|
||||
/// 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.
|
||||
/// </div>
|
||||
/// 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<Tiles>, 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),
|
||||
|
|
|
@ -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<u8>;
|
|||
/// A grid containing UTF-8 characters.
|
||||
pub type CharGrid = PrimitiveGrid<char>;
|
||||
|
||||
/// 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 {
|
||||
|
|
Loading…
Reference in a new issue