mirror of
https://github.com/bspeice/kaitai_rust
synced 2024-12-26 06:18:11 -05:00
Remove bad docs, make parent a KStruct
This commit is contained in:
parent
9723f0b12d
commit
a079b75c6e
@ -16,7 +16,7 @@ impl<'a> From<io::Error> for KError<'a> {
|
||||
pub type KResult<'a, T> = Result<T, KError<'a>>;
|
||||
|
||||
pub trait KStruct<'a> {
|
||||
type Parent: ?KStruct<'a>;
|
||||
type Parent: KStruct<'a>;
|
||||
type Root: KStruct<'a>;
|
||||
|
||||
/// Create a new instance of this struct; if we are the root node,
|
||||
@ -68,8 +68,6 @@ pub trait KStream {
|
||||
eos_error: bool,
|
||||
) -> io::Result<&[u8]>;
|
||||
|
||||
/// Verify a magic sequence occurs in the file. Because the size is known at compile-time
|
||||
/// (and is generally very small), we ask that our caller pass in a buffer for us.
|
||||
fn ensure_fixed_contents(&mut self, expected: &[u8]) -> KResult<&[u8]> {
|
||||
let actual = self.read_bytes(expected.len())?;
|
||||
if actual == expected {
|
||||
@ -83,8 +81,7 @@ pub trait KStream {
|
||||
}
|
||||
|
||||
/// Return a byte array that is sized to exclude all trailing instances of the
|
||||
/// padding character. Because this operation is immutable on the underlying byte slice,
|
||||
/// we don't allocate a second buffer.
|
||||
/// padding character.
|
||||
fn bytes_strip_right(bytes: &[u8], pad: u8) -> &[u8] {
|
||||
let mut new_len = bytes.len();
|
||||
while new_len > 0 && bytes[new_len - 1] == pad {
|
||||
@ -95,8 +92,6 @@ pub trait KStream {
|
||||
|
||||
/// Return a byte array that contains all bytes up until the
|
||||
/// termination byte. Can optionally include the termination byte as well.
|
||||
/// Because this operation is immutable on the underlying byte slice,
|
||||
/// we don't allocate a second buffer.
|
||||
fn bytes_terminate(bytes: &[u8], term: u8, include_term: bool) -> &[u8] {
|
||||
let mut new_len = 0;
|
||||
while bytes[new_len] != term && new_len < bytes.len() {
|
||||
|
Loading…
Reference in New Issue
Block a user