better naming
This commit is contained in:
parent
38b789ca6d
commit
4c1101f65f
14
src/ecss.rs
14
src/ecss.rs
@ -169,7 +169,7 @@ pub trait EcssEnumeration {
|
||||
fn byte_width(&self) -> usize {
|
||||
(self.pfc() / 8) as usize
|
||||
}
|
||||
fn write_to_bytes(&self, buf: &mut [u8]) -> Result<(), ByteConversionError>;
|
||||
fn write_to_be_bytes(&self, buf: &mut [u8]) -> Result<(), ByteConversionError>;
|
||||
}
|
||||
|
||||
pub trait EcssEnumerationExt: EcssEnumeration + Debug + Copy + Clone + PartialEq + Eq {}
|
||||
@ -231,7 +231,7 @@ impl<TYPE: ToBeBytes> EcssEnumeration for GenericEcssEnumWrapper<TYPE> {
|
||||
size_of::<TYPE>() as u8 * 8_u8
|
||||
}
|
||||
|
||||
fn write_to_bytes(&self, buf: &mut [u8]) -> Result<(), ByteConversionError> {
|
||||
fn write_to_be_bytes(&self, buf: &mut [u8]) -> Result<(), ByteConversionError> {
|
||||
if buf.len() < self.byte_width() as usize {
|
||||
return Err(ByteConversionError::ToSliceTooSmall(SizeMissmatch {
|
||||
found: buf.len(),
|
||||
@ -263,7 +263,7 @@ mod tests {
|
||||
let mut buf = [0, 0, 0];
|
||||
let my_enum = EcssEnumU8::new(1);
|
||||
my_enum
|
||||
.write_to_bytes(&mut buf[1..2])
|
||||
.write_to_be_bytes(&mut buf[1..2])
|
||||
.expect("To byte conversion of u8 failed");
|
||||
assert_eq!(buf[1], 1);
|
||||
}
|
||||
@ -273,7 +273,7 @@ mod tests {
|
||||
let mut buf = [0, 0, 0];
|
||||
let my_enum = EcssEnumU16::new(0x1f2f);
|
||||
my_enum
|
||||
.write_to_bytes(&mut buf[1..3])
|
||||
.write_to_be_bytes(&mut buf[1..3])
|
||||
.expect("To byte conversion of u8 failed");
|
||||
assert_eq!(buf[1], 0x1f);
|
||||
assert_eq!(buf[2], 0x2f);
|
||||
@ -283,7 +283,7 @@ mod tests {
|
||||
fn test_slice_u16_too_small() {
|
||||
let mut buf = [0];
|
||||
let my_enum = EcssEnumU16::new(0x1f2f);
|
||||
let res = my_enum.write_to_bytes(&mut buf[0..1]);
|
||||
let res = my_enum.write_to_be_bytes(&mut buf[0..1]);
|
||||
assert!(res.is_err());
|
||||
let error = res.unwrap_err();
|
||||
match error {
|
||||
@ -302,7 +302,7 @@ mod tests {
|
||||
let mut buf = [0, 0, 0, 0, 0];
|
||||
let my_enum = EcssEnumU32::new(0x1f2f3f4f);
|
||||
my_enum
|
||||
.write_to_bytes(&mut buf[1..5])
|
||||
.write_to_be_bytes(&mut buf[1..5])
|
||||
.expect("To byte conversion of u8 failed");
|
||||
assert_eq!(buf[1], 0x1f);
|
||||
assert_eq!(buf[2], 0x2f);
|
||||
@ -314,7 +314,7 @@ mod tests {
|
||||
fn test_slice_u32_too_small() {
|
||||
let mut buf = [0, 0, 0, 0, 0];
|
||||
let my_enum = EcssEnumU32::new(0x1f2f3f4f);
|
||||
let res = my_enum.write_to_bytes(&mut buf[0..3]);
|
||||
let res = my_enum.write_to_be_bytes(&mut buf[0..3]);
|
||||
assert!(res.is_err());
|
||||
let error = res.unwrap_err();
|
||||
match error {
|
||||
|
Loading…
Reference in New Issue
Block a user