From 0e370556a2a796d837d0aa242d26feb93485423b Mon Sep 17 00:00:00 2001 From: Tangent 128 Date: Mon, 16 Apr 2018 01:58:28 -0400 Subject: [PATCH] add a little documentation re: soft buffer limits --- src/chunk.rs | 5 ++++- src/commands/relay.rs | 4 ++-- src/stream_parser.rs | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/chunk.rs b/src/chunk.rs index 3f6df32..b81d16f 100644 --- a/src/chunk.rs +++ b/src/chunk.rs @@ -96,7 +96,10 @@ pub struct WebmChunker { } impl WebmChunker { - pub fn with_buffer_limit(mut self, limit: usize) -> Self { + /// add a "soft" buffer size limit; if a chunk buffer exceeds this size, + /// error the stream instead of resuming. It's still possible for a buffer + /// to exceed this size *after* a write, so ensure input sizes are reasonable. + pub fn with_soft_limit(mut self, limit: usize) -> Self { self.buffer_size_limit = Some(limit); self } diff --git a/src/commands/relay.rs b/src/commands/relay.rs index d213601..17bc018 100644 --- a/src/commands/relay.rs +++ b/src/commands/relay.rs @@ -64,8 +64,8 @@ impl RelayServer { where S::Error: Error + Send { let source = stream .map_err(WebmetroError::from_err) - .parse_ebml().with_buffer_limit(BUFFER_LIMIT) - .chunk_webm().with_buffer_limit(BUFFER_LIMIT); + .parse_ebml().with_soft_limit(BUFFER_LIMIT) + .chunk_webm().with_soft_limit(BUFFER_LIMIT); let sink = Transmitter::new(self.get_channel()); Box::new( diff --git a/src/stream_parser.rs b/src/stream_parser.rs index 58d215b..0d3c9cb 100644 --- a/src/stream_parser.rs +++ b/src/stream_parser.rs @@ -15,7 +15,10 @@ pub struct EbmlStreamingParser { } impl EbmlStreamingParser { - pub fn with_buffer_limit(mut self, limit: usize) -> Self { + /// add a "soft" buffer size limit; if the input buffer exceeds this size, + /// error the stream instead of resuming. It's still possible for the buffer + /// to exceed this size *after* a fill, so ensure input sizes are reasonable. + pub fn with_soft_limit(mut self, limit: usize) -> Self { self.buffer_size_limit = Some(limit); self }