diff --git a/um_wasm/src/exports/ncm.rs b/um_wasm/src/exports/ncm.rs index 4e41773..5bc49ac 100644 --- a/um_wasm/src/exports/ncm.rs +++ b/um_wasm/src/exports/ncm.rs @@ -19,22 +19,25 @@ impl JsNCMFile { /// Open NCM file. /// If everything is ok, return `0`. + /// If it needs more header bytes, return positive integer. + /// If it was not a valid NCM file, return -1. /// /// # Arguments /// /// * `header`: Header bytes of NCM file. /// - /// returns: Result + /// returns: Result /// /// If it needs more bytes, the new header size will be returned. /// If the header was large enough, it will return 0. - pub fn open(&mut self, header: &[u8]) -> Result { + pub fn open(&mut self, header: &[u8]) -> Result { match NCMFile::new(header) { Ok(ncm) => { self.ncm = Some(ncm); Ok(0) } - Err(NetEaseCryptoError::HeaderTooSmall(n)) => Ok(n), + Err(NetEaseCryptoError::HeaderTooSmall(n)) => Ok(n as i32), + Err(NetEaseCryptoError::NotNCMFile) => Ok(-1), Err(err) => Err(JsError::new(err.to_string().as_str())), } }