More clippy suggestions
This commit is contained in:
3 files changed
+10
-10
No files matched your search
+4
-4
@@ -102,7 +102,7 @@ pub(crate) fn adpcm_to_pcm(bytes: &[u8]) -> Result<Vec<u8>, Error> {
|
||||
|
||||
if bytes.len() < 4 {
|
||||
error!("ADPCM data is too short for even the magic.");
|
||||
return Err(Error::AdpcmDecodingError(
|
||||
return Err(Error::AdpcmDecoding(
|
||||
"ADPCM data is too short for even the magic.",
|
||||
));
|
||||
}
|
||||
@@ -112,7 +112,7 @@ pub(crate) fn adpcm_to_pcm(bytes: &[u8]) -> Result<Vec<u8>, Error> {
|
||||
const FRAME_TYPE_HISILICON: &[u8] = &[0x00, 0x01];
|
||||
if frame_type_bytes != FRAME_TYPE_HISILICON {
|
||||
error!("Unexpected ADPCM frame type: {:x?}", frame_type_bytes);
|
||||
return Err(Error::AdpcmDecodingError("Unexpected ADPCM frame type"));
|
||||
return Err(Error::AdpcmDecoding("Unexpected ADPCM frame type"));
|
||||
}
|
||||
|
||||
// Check for valid block size
|
||||
@@ -126,7 +126,7 @@ pub(crate) fn adpcm_to_pcm(bytes: &[u8]) -> Result<Vec<u8>, Error> {
|
||||
let full_block_size = block_size + 4; // block_size + magic (2 bytes) + size (2 bytes)
|
||||
if !bytes.len() % full_block_size as usize == 0 {
|
||||
error!("ADPCM Data is not a multiple of the block size");
|
||||
return Err(Error::AdpcmDecodingError(
|
||||
return Err(Error::AdpcmDecoding(
|
||||
"ADPCM block size does not match data length.",
|
||||
));
|
||||
}
|
||||
@@ -136,7 +136,7 @@ pub(crate) fn adpcm_to_pcm(bytes: &[u8]) -> Result<Vec<u8>, Error> {
|
||||
// Get predictor state from block header using DVI 4 format.
|
||||
if bytes.len() < 8 {
|
||||
error!("ADPCM Block size is not long enough for header");
|
||||
return Err(Error::AdpcmDecodingError(
|
||||
return Err(Error::AdpcmDecoding(
|
||||
"ADPCM has insufficent block size",
|
||||
));
|
||||
}
|
||||
|
||||
+5
-5
@@ -6,18 +6,18 @@ use err_derive::Error;
|
||||
pub enum Error {
|
||||
/// Raised when the config file fails to deserlize
|
||||
#[error(display = "Configuration parsing error")]
|
||||
ConfigError(#[error(source)] toml::de::Error),
|
||||
Config(#[error(source)] toml::de::Error),
|
||||
/// Raised when `neolink_core` raises an error
|
||||
#[error(display = "Communication error")]
|
||||
ProtocolError(#[error(source)] neolink_core::Error),
|
||||
Protocol(#[error(source)] neolink_core::Error),
|
||||
/// Raised when there is an IO error such as unable to find
|
||||
/// config file
|
||||
#[error(display = "I/O error")]
|
||||
IoError(#[error(source)] std::io::Error),
|
||||
Io(#[error(source)] std::io::Error),
|
||||
/// Raised when the config file fails validataion
|
||||
#[error(display = "Validation error")]
|
||||
ValidationError(#[error(source)] validator::ValidationErrors),
|
||||
Validation(#[error(source)] validator::ValidationErrors),
|
||||
/// Raised when there is an ADPCM decoding error
|
||||
#[error(display = "ADPCM Decoding Error")]
|
||||
AdpcmDecodingError(&'static str),
|
||||
AdpcmDecoding(&'static str),
|
||||
}
|
||||
+1
-1
@@ -41,7 +41,7 @@ impl StreamOutput for GstOutputs {
|
||||
self.set_format(Some(format));
|
||||
if let StreamFormat::ADPCM = format {
|
||||
let pcm = adpcm_to_pcm(data).map_err(|e| {
|
||||
if let Error::AdpcmDecodingError(msg) = e {
|
||||
if let Error::AdpcmDecoding(msg) = e {
|
||||
neolink_core::Error::OtherString(format!("ADPCM decoding error: {}", msg))
|
||||
} else {
|
||||
neolink_core::Error::Other("Generic error during ADPCM decoding")
|
||||
|
||||
Reference in new issue
Block a user