Read
Read (읽기 트레이트)
바이트를 읽을 수 있는 소스에 대한 트레이트예요.
출처: Rust 공식 문서
본문
바이트를 읽을 수 있는 소스에 대한 트레이트예요. 메서드는 read 가 핵심이며, 읽은 바이트 수를 반환해요. read_to_string, read_to_end, read_exact 등 기본 메서드들이 있어요. 락을 잡고 반복해서 읽어서 나머지를 버퍼에 채워 넣기를 기대해요.
pub trait Read { Show 15 methods // Required method fn read (&mut self, buf: &mut [ u8 ]) -> Result < usize >; // Provided methods fn read_vectored (&mut self, bufs: &mut [ IoSliceMut <'_>]) -> Result < usize > { ... } fn is_read_vectored (&self) -> bool { ... } fn read_to_end (&mut self, buf: &mut Vec < u8 >) -> Result < usize > { ... } fn read_to_string (&mut self, buf: &mut String ) -> Result < usize > { ... } fn read_exact (&mut self, buf: &mut [ u8 ]) -> Result < () > { ... } fn read_buf (&mut self, buf: BorrowedCursor <'_, u8 >) -> Result < () > { ... } fn read_buf_exact (&mut self, cursor: BorrowedCursor <'_, u8 >) -> Result < () > { ... } fn by_ref (&mut self) -> &mut Self where Self: Sized { ... } fn bytes (self) -> Bytes <Self> ⓘ where Self: Sized { ... } fn chain <R: Read >(self, next: R) -> Chain <Self, R> ⓘ where Self: Sized { ... } fn take (self, limit: u64 ) -> Take <Self> ⓘ where Self: Sized { ... } fn read_array <const N: usize >(&mut self) -> Result <[ u8 ; N ]> where Self: Sized { ... } fn read_le <T: FromEndianBytes >(&mut self) -> Result <T> where Self: Sized { ... } fn read_be <T: FromEndianBytes >(&mut self) -> Result <T> where Self: Sized { ... } }