Remove bad docs, make parent a KStruct

This commit is contained in:
Bradlee Speice 2019-04-23 13:02:31 -04:00
parent 9723f0b12d
commit a079b75c6e

View File

@ -16,7 +16,7 @@ impl<'a> From<io::Error> for KError<'a> {
pub type KResult<'a, T> = Result<T, KError<'a>>; pub type KResult<'a, T> = Result<T, KError<'a>>;
pub trait KStruct<'a> { pub trait KStruct<'a> {
type Parent: ?KStruct<'a>; type Parent: KStruct<'a>;
type Root: KStruct<'a>; type Root: KStruct<'a>;
/// Create a new instance of this struct; if we are the root node, /// Create a new instance of this struct; if we are the root node,
@ -68,8 +68,6 @@ pub trait KStream {
eos_error: bool, eos_error: bool,
) -> io::Result<&[u8]>; ) -> 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]> { fn ensure_fixed_contents(&mut self, expected: &[u8]) -> KResult<&[u8]> {
let actual = self.read_bytes(expected.len())?; let actual = self.read_bytes(expected.len())?;
if actual == expected { if actual == expected {
@ -83,8 +81,7 @@ pub trait KStream {
} }
/// Return a byte array that is sized to exclude all trailing instances of the /// 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, /// padding character.
/// we don't allocate a second buffer.
fn bytes_strip_right(bytes: &[u8], pad: u8) -> &[u8] { fn bytes_strip_right(bytes: &[u8], pad: u8) -> &[u8] {
let mut new_len = bytes.len(); let mut new_len = bytes.len();
while new_len > 0 && bytes[new_len - 1] == pad { 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 /// Return a byte array that contains all bytes up until the
/// termination byte. Can optionally include the termination byte as well. /// 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] { fn bytes_terminate(bytes: &[u8], term: u8, include_term: bool) -> &[u8] {
let mut new_len = 0; let mut new_len = 0;
while bytes[new_len] != term && new_len < bytes.len() { while bytes[new_len] != term && new_len < bytes.len() {