Module stream_download::storage::bounded

source ·
Expand description

Storage wrappers for restricting the size of the underlying storage layer. This is useful for dealing with infinite streams when you don’t want the storage size to keep growing indefinitely. It can also be used for downloading large files where you want to prevent allocating too much space at one time.

The underlying data is used as a circular buffer - once it reaches capacity, it will begin to overwrite old data.

Because the buffer will never resize, it’s important to ensure the buffer is large enough to hold all of the data you will need at once. This needs to account for any seeking that may occur as well as the size of the initial prefetch phase.

If your inputs may or may not have a known content length, consider using an AdaptiveStorageProvider to automatically determine whether or not the overhead of maintaining a bounded buffer is necessary.