MCPcopy Index your code
hub / github.com/RustPython/RustPython / Read

Interface Read

crates/compiler-core/src/marshal.rs:120–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120pub trait Read {
121 fn read_slice(&mut self, n: u32) -> Result<&[u8]>;
122
123 fn read_array<const N: usize>(&mut self) -> Result<&[u8; N]> {
124 self.read_slice(N as u32).map(|s| s.try_into().unwrap())
125 }
126
127 fn read_str(&mut self, len: u32) -> Result<&str> {
128 Ok(core::str::from_utf8(self.read_slice(len)?)?)
129 }
130
131 fn read_wtf8(&mut self, len: u32) -> Result<&Wtf8> {
132 Wtf8::from_bytes(self.read_slice(len)?).ok_or(MarshalError::InvalidUtf8)
133 }
134
135 fn read_u8(&mut self) -> Result<u8> {
136 Ok(u8::from_le_bytes(*self.read_array()?))
137 }
138
139 fn read_u16(&mut self) -> Result<u16> {
140 Ok(u16::from_le_bytes(*self.read_array()?))
141 }
142
143 fn read_u32(&mut self) -> Result<u32> {
144 Ok(u32::from_le_bytes(*self.read_array()?))
145 }
146
147 fn read_u64(&mut self) -> Result<u64> {
148 Ok(u64::from_le_bytes(*self.read_array()?))
149 }
150}
151
152pub(crate) trait ReadBorrowed<'a>: Read {
153 fn read_slice_borrow(&mut self, n: u32) -> Result<&'a [u8]>;

Callers 3

py_newMethod · 0.85
ReadFileMethod · 0.85
WSARecvMethod · 0.85

Implementers 3

openssl.rscrates/stdlib/src/openssl.rs
socket.rscrates/stdlib/src/socket.rs
marshal.rscrates/compiler-core/src/marshal.rs

Calls

no outgoing calls

Tested by

no test coverage detected