pub trait BufferExt {
// Required methods
fn read_all(&self) -> Vec<u8> ⓘ;
fn read_to_string(&self) -> VtxResult<String>;
fn read_json<T: DeserializeOwned>(&self) -> VtxResult<T>;
fn write_all(&self, data: impl AsRef<[u8]>) -> u64;
}Expand description
Buffer 资源的便捷扩展方法。
Required Methods§
Sourcefn read_all(&self) -> Vec<u8> ⓘ
fn read_all(&self) -> Vec<u8> ⓘ
读取整个 Buffer。
- 对于 file/memory:使用
size()做分块读取。 - 对于 pipe:会持续读取直到 EOF(返回空数组)或到达
max_total_bytes。
Sourcefn read_to_string(&self) -> VtxResult<String>
fn read_to_string(&self) -> VtxResult<String>
按 UTF-8 读取整个 Buffer。
Sourcefn read_json<T: DeserializeOwned>(&self) -> VtxResult<T>
fn read_json<T: DeserializeOwned>(&self) -> VtxResult<T>
将 Buffer 中的 JSON 反序列化为目标类型。
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.