5a1de1acd2
When no piece length is provided to imdl torrent create, a piece length is selected based on the size of the input. The hueristic is lifted directly from libtorrent. Also adds a imdl torrent piece-length command, which prints a table of the piece lengths chosen at different content sizes, which is useful for understanding and debugging the piece length selection algorithm. type: added
26 lines
480 B
Rust
26 lines
480 B
Rust
use crate::common::*;
|
|
|
|
pub(crate) struct Linter {
|
|
allowed: BTreeSet<Lint>,
|
|
}
|
|
|
|
impl Linter {
|
|
pub(crate) fn new() -> Linter {
|
|
Linter {
|
|
allowed: BTreeSet::new(),
|
|
}
|
|
}
|
|
|
|
pub(crate) fn allow(&mut self, allowed: impl IntoIterator<Item = Lint>) {
|
|
self.allowed.extend(allowed)
|
|
}
|
|
|
|
pub(crate) fn is_allowed(&self, lint: Lint) -> bool {
|
|
self.allowed.contains(&lint)
|
|
}
|
|
|
|
pub(crate) fn is_denied(&self, lint: Lint) -> bool {
|
|
!self.is_allowed(lint)
|
|
}
|
|
}
|