[][src]Struct readfilter::CharWhitelist

pub struct CharWhitelist<T> where
    T: Read
{ /* fields omitted */ }

Removes all non-whitelisted characters from the wrapped stream.

Non-utf8 characters are lost due to internal string conversions using String::from_utf8_lossy().

use readfilter::CharWhitelist;
use std::io::Read;
let buf = "aabbccddee".as_bytes();
let mut wrapped = CharWhitelist::new(buf, "ace");
let mut s = String::new();
wrapped.read_to_string(&mut s).unwrap();
assert_eq!(&s, "aaccee");
use readfilter::CharWhitelist;
use std::fs::OpenOptions;
use std::io::Read;
let mut output = vec![];
let fd = OpenOptions::new().read(true).open("input.txt").unwrap();
let mut input = CharWhitelist::new(fd, "01");
input.read_to_end(&mut output);
// output only contains the '0' and '1' characters from input.txt


impl<T> CharWhitelist<T> where
    T: Read

pub fn new(source: T, allowed_chars: &str) -> Self[src]

Trait Implementations

impl<T> Read for CharWhitelist<T> where
    T: Read

Auto Trait Implementations

impl<T> RefUnwindSafe for CharWhitelist<T> where
    T: RefUnwindSafe

impl<T> Send for CharWhitelist<T> where
    T: Send

impl<T> Sync for CharWhitelist<T> where
    T: Sync

impl<T> Unpin for CharWhitelist<T> where
    T: Unpin

impl<T> UnwindSafe for CharWhitelist<T> where
    T: UnwindSafe

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = !

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.