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.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/matroska/src/write.rs b/matroska/src/write.rs
index ee1c44c..8c1e7bb 100644
--- a/matroska/src/write.rs
+++ b/matroska/src/write.rs
@@ -26,6 +26,10 @@ impl EbmlWriter {
Ok(())
}
+ pub fn position(&self) -> usize {
+ self.position
+ }
+
pub fn write_padding(&mut self, position: usize) -> Result<()> {
let mut size = position - self.position;
match size {
@@ -62,14 +66,17 @@ impl EbmlWriter {
if i > (1 << 56) - 1 {
bail!("vint does not fit");
}
+ self.write_vint_len(i, Self::vint_length(i))
+ }
+ pub fn vint_length(v: u64) -> usize {
let mut len = 1;
while len <= 8 {
- if i < (1 << ((7 * len) - 1)) {
+ if v < (1 << ((7 * len) - 1)) {
break;
}
len += 1;
}
- self.write_vint_len(i, len)
+ len
}
pub fn write_vint_len(&mut self, i: u64, len: usize) -> Result<()> {
let mut bytes = i.to_be_bytes();