pub trait LuaFileHandle: Send {
// Required methods
fn read_byte(&mut self) -> i32;
fn unread_byte(&mut self, byte: i32);
fn write_bytes(&mut self, data: &[u8]) -> Result<usize>;
fn flush(&mut self) -> Result<()>;
fn seek(&mut self, pos: SeekFrom) -> Result<u64>;
fn tell(&mut self) -> Result<u64>;
fn clear_error(&mut self);
fn has_error(&self) -> bool;
// Provided method
fn set_buf_mode(&mut self, _mode: i32, _size: usize) -> Result<()> { ... }
}Expand description
Capabilities required by the io library from an OS file handle.
Designed to be object-safe (Box<dyn LuaFileHandle>). Implementations
backed by std::fs::File live in lua-cli; implementations for the
standard streams live in lua-stdlib/src/io_lib.rs.
Required Methods§
Sourcefn read_byte(&mut self) -> i32
fn read_byte(&mut self) -> i32
Read one byte from the handle; return it as i32, or -1 on EOF/error.
Sourcefn unread_byte(&mut self, byte: i32)
fn unread_byte(&mut self, byte: i32)
Push back a previously-read byte so the next read_byte returns it.
Sourcefn write_bytes(&mut self, data: &[u8]) -> Result<usize>
fn write_bytes(&mut self, data: &[u8]) -> Result<usize>
Write a byte slice; return the number of bytes actually written.
Sourcefn clear_error(&mut self)
fn clear_error(&mut self)
Clear the error/EOF flag on the handle.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".