error
This commit is contained in:
parent
065579647f
commit
4929f19bf0
24
src/lib.rs
24
src/lib.rs
@ -1,14 +1,26 @@
|
||||
mod bsp;
|
||||
|
||||
pub fn read<R:std::io::Read>(mut input:R)->vbsp::BspResult<vbsp::Bsp>{
|
||||
pub struct Bsp(vbsp::Bsp);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ReadError{
|
||||
Bsp(vbsp::BspError),
|
||||
Io(std::io::Error),
|
||||
}
|
||||
impl std::fmt::Display for ReadError{
|
||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||
write!(f,"{self:?}")
|
||||
}
|
||||
}
|
||||
impl std::error::Error for ReadError{}
|
||||
|
||||
pub fn read<R:std::io::Read>(mut input:R)->Result<Bsp,ReadError>{
|
||||
let mut s=Vec::new();
|
||||
|
||||
match input.read_to_end(&mut s){
|
||||
Ok(_)=>(),
|
||||
Err(e)=>println!("load_bsp::convert read_to_end failed: {:?}",e),
|
||||
}
|
||||
//TODO: mmap
|
||||
input.read_to_end(&mut s).map_err(ReadError::Io)?;
|
||||
|
||||
vbsp::Bsp::read(s.as_slice())
|
||||
vbsp::Bsp::read(s.as_slice()).map(Bsp).map_err(ReadError::Bsp)
|
||||
}
|
||||
|
||||
pub fn convert<AcquireTextureId,AcquireMeshId>(
|
||||
|
Loading…
x
Reference in New Issue
Block a user