Skip to main content

TextConversion

Trait TextConversion 

Source
pub trait TextConversion {
    // Required methods
    fn new(line_terminator: Vec<u8>) -> Self;
    fn from_utf8(&self, txt: &str) -> Option<Vec<u8>>;
    fn to_utf8(&self, src: &[u8]) -> Option<String>;

    // Provided method
    fn is_terminated(bytes: &[u8], term: &[u8]) -> bool { ... }
}

Required Methods§

Source

fn new(line_terminator: Vec<u8>) -> Self

Source

fn from_utf8(&self, txt: &str) -> Option<Vec<u8>>

Typical implementations will return Some(Vec) only if the string slice is pure ASCII.

Source

fn to_utf8(&self, src: &[u8]) -> Option<String>

Typical implementations will return Some(String) always. If src has something out of bounds, it will be replaced with ASCII NULL. Consumers can then judge the result by calling null_fraction.

Provided Methods§

Source

fn is_terminated(bytes: &[u8], term: &[u8]) -> bool

Does a given slice end with another slice

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl TextConversion for a2kit::fs::dos3x::types::TextConverter

Source§

impl TextConversion for a2kit::fs::prodos::types::TextConverter

Source§

impl TextConversion for a2kit::fs::pascal::types::TextConverter

Source§

impl TextConversion for a2kit::fs::cpm::types::TextConverter