master
an 2019-05-30 21:29:37 -04:00
parent 651efd1f32
commit 022ef81f38
6 changed files with 16 additions and 18 deletions

View File

@ -374,8 +374,9 @@ pub fn rd_array<T, F>(b: &[u8], read: F) -> ResultS<Vec<T>>
/// # Errors /// # Errors
/// ///
/// Execution will return the result of `read` if `read` returns an error. /// Execution will return the result of `read` if `read` returns an error.
pub fn rd_array_num<T, F>(b: &[u8], n: usize, read: F) pub fn rd_array_num<T, F>(b: &[u8],
-> ResultS<(Vec<T>, usize)> n: usize,
read: F) -> ResultS<(Vec<T>, usize)>
where T: Sized, where T: Sized,
F: Fn(&[u8]) -> ResultS<(T, usize)> F: Fn(&[u8]) -> ResultS<(T, usize)>
{ {
@ -409,8 +410,7 @@ pub fn rd_array_num<T, F>(b: &[u8], n: usize, read: F)
pub fn rd_ofstable<T, F>(b: &[u8], pub fn rd_ofstable<T, F>(b: &[u8],
mut p: usize, mut p: usize,
num: usize, num: usize,
read: F) read: F) -> ResultS<Vec<T>>
-> ResultS<Vec<T>>
where T: Sized, where T: Sized,
F: Fn(&[u8]) -> ResultS<T> F: Fn(&[u8]) -> ResultS<T>
{ {

View File

@ -45,8 +45,7 @@ impl Sound16
} }
/// Creates a new `Sound16` from an unsigned 8-bit stream. /// Creates a new `Sound16` from an unsigned 8-bit stream.
pub fn new_from_8(rate: u16, lp_beg: usize, lp_end: usize, b: &[u8]) pub fn new_from_8(rate: u16, lp_beg: usize, lp_end: usize, b: &[u8]) -> Self
-> Self
{ {
let mut snd = Self::new(rate, lp_beg, lp_end, b.len()); let mut snd = Self::new(rate, lp_beg, lp_end, b.len());
@ -58,8 +57,7 @@ impl Sound16
} }
/// Creates a new `Sound16` from a signed 16-bit stream. /// Creates a new `Sound16` from a signed 16-bit stream.
pub fn new_from_16(rate: u16, lp_beg: usize, lp_end: usize, b: &[u8]) pub fn new_from_16(rate: u16, lp_beg: usize, lp_end: usize, b: &[u8]) -> Self
-> Self
{ {
let mut snd = Self::new(rate, lp_beg, lp_end, b.len() / 2); let mut snd = Self::new(rate, lp_beg, lp_end, b.len() / 2);

View File

@ -214,8 +214,7 @@ fn stream_literal(v: &mut Vec<u8>, b: &[u8], p: usize) -> ResultS<usize>
fn read_alphabet(b: &[u8], fn read_alphabet(b: &[u8],
mut p: usize, mut p: usize,
alphabet: &mut [u16], alphabet: &mut [u16],
code_table: HuffmanTable) code_table: HuffmanTable) -> ResultS<usize>
-> ResultS<usize>
{ {
let mut i = 0; let mut i = 0;
while i < alphabet.len() { while i < alphabet.len() {
@ -280,8 +279,7 @@ fn output_tables(v: &mut Vec<u8>,
b: &[u8], b: &[u8],
mut p: usize, mut p: usize,
table_len: HuffmanTable, table_len: HuffmanTable,
table_dst: HuffmanTable) table_dst: HuffmanTable) -> ResultS<usize>
-> ResultS<usize>
{ {
const LEN_BASE: [usize; 29] = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, const LEN_BASE: [usize; 29] = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19,
23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115,

View File

@ -10,8 +10,7 @@ pub fn read(b: &[u8],
old_dat: bool, old_dat: bool,
siz_app: usize, siz_app: usize,
siz_ent: usize, siz_ent: usize,
siz_cnk: usize) siz_cnk: usize) -> ResultS<EntryMap>
-> ResultS<EntryMap>
{ {
read_data! { read_data! {
endian: BIG, buf: b, size: 128, start: 0, data { endian: BIG, buf: b, size: 128, start: 0, data {

View File

@ -9,8 +9,9 @@ pub mod sequ;
use crate::durandal::{bin::usize_from_u32, err::*}; use crate::durandal::{bin::usize_from_u32, err::*};
/// Reads a collection at an offset provided by the Shapes header. /// Reads a collection at an offset provided by the Shapes header.
pub fn read_coll_at_offset(b: &[u8], ofs: u32, len: usize) pub fn read_coll_at_offset(b: &[u8],
-> ResultS<Option<coll::Collection>> ofs: u32,
len: usize) -> ResultS<Option<coll::Collection>>
{ {
if ofs != u32::max_value() { if ofs != u32::max_value() {
let ofs = usize_from_u32(ofs); let ofs = usize_from_u32(ofs);

View File

@ -29,8 +29,10 @@ pub fn read_color(b: &[u8], clut: &mut [ColorShp]) -> ResultS<()>
} }
/// Reads color tables from `b`. /// Reads color tables from `b`.
pub fn read(b: &[u8], tab_ofs: usize, tab_num: usize, clr_num: usize) pub fn read(b: &[u8],
-> ResultS<Vec<Clut>> tab_ofs: usize,
tab_num: usize,
clr_num: usize) -> ResultS<Vec<Clut>>
{ {
let end = tab_num * clr_num * 8; let end = tab_num * clr_num * 8;