aboutsummaryrefslogtreecommitdiff
path: root/matroska/src/write.rs
diff options
context:
space:
mode:
Diffstat (limited to 'matroska/src/write.rs')
-rw-r--r--matroska/src/write.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/matroska/src/write.rs b/matroska/src/write.rs
index 8c1e7bb..6f8aad4 100644
--- a/matroska/src/write.rs
+++ b/matroska/src/write.rs
@@ -82,7 +82,7 @@ impl EbmlWriter {
let mut bytes = i.to_be_bytes();
let trunc = &mut bytes[(8 - len)..];
trunc[0] |= 1 << (8 - len);
- self.write(&trunc)
+ self.write(trunc)
}
}
@@ -103,7 +103,7 @@ pub trait WriteValue {
impl WriteValue for i64 {
fn write_to(&self, w: &mut Vec<u8>) -> Result<()> {
- Ok(match 64 - self.leading_zeros() {
+ match 64 - self.leading_zeros() {
x if x <= 8 => {
w.push(0x81);
w.extend_from_slice(&(*self as i8).to_be_bytes());
@@ -120,12 +120,13 @@ impl WriteValue for i64 {
w.push(0x88);
w.extend_from_slice(&self.to_be_bytes());
}
- })
+ };
+ Ok(())
}
}
impl WriteValue for u64 {
fn write_to(&self, w: &mut Vec<u8>) -> Result<()> {
- Ok(match 64 - self.leading_zeros() {
+ match 64 - self.leading_zeros() {
x if x <= 8 => {
w.push(0x81);
w.extend_from_slice(&(*self as u8).to_be_bytes());
@@ -142,7 +143,8 @@ impl WriteValue for u64 {
w.push(0x88);
w.extend_from_slice(&self.to_be_bytes());
}
- })
+ };
+ Ok(())
}
}
impl WriteValue for f64 {
@@ -155,7 +157,7 @@ impl WriteValue for f64 {
impl WriteValue for Vec<u8> {
fn write_to(&self, w: &mut Vec<u8>) -> Result<(), anyhow::Error> {
write_vint(w, self.len() as u64)?;
- w.extend_from_slice(&self);
+ w.extend_from_slice(self);
Ok(())
}
}
@@ -181,7 +183,10 @@ impl WriteValue for Master {
fn write_to(&self, w: &mut Vec<u8>) -> Result<()> {
match self {
Master::Start => EbmlSize::Unknown.write_to(w),
- Master::End => Ok(w.clear()),
+ Master::End => {
+ w.clear();
+ Ok(())
+ }
Master::Collected(c) => {
let mut ib = vec![];
for c in c {
@@ -203,6 +208,6 @@ pub fn write_vint(w: &mut Vec<u8>, i: u64) -> Result<()> {
let mut bytes = i.to_be_bytes();
let trunc = &mut bytes[(8 - len)..];
trunc[0] |= 1 << (8 - len);
- w.extend_from_slice(&trunc);
+ w.extend_from_slice(trunc);
Ok(())
}