BufRead
BufRead (버퍼 읽기 트레이트)
내부 버퍼가 있어 추가적인 읽기 방식을 수행할 수 있는 Read 유형이에요.
출처: Rust 공식 문서
본문
내부 버퍼가 있어 추가적인 읽기 방식을 수행할 수 있는 Read 유형이에요. 예를 들어 줄 단위 읽기는 버퍼 없이는 비효율적이에요. BufRead 는 read_line 메서드와 lines 이터레이터를 포함해요. fill_buf 와 consume 으로 버퍼에 직접 접근할 수 있어요.
pub trait BufRead: Read { // Required methods fn fill_buf (&mut self) -> Result <&[ u8 ]>; fn consume (&mut self, amount: usize ); // Provided methods fn has_data_left (&mut self) -> Result < bool > { ... } fn read_until (&mut self, byte: u8 , buf: &mut Vec < u8 >) -> Result < usize > { ... } fn skip_until (&mut self, byte: u8 ) -> Result < usize > { ... } fn read_line (&mut self, buf: &mut String ) -> Result < usize > { ... } fn split (self, byte: u8 ) -> Split <Self> ⓘ where Self: Sized { ... } fn lines (self) -> Lines <Self> ⓘ where Self: Sized { ... } }