pub enum FileSelection {
Single(usize),
Range(usize, usize),
}Expand description
A file selection entry from a BEP 53 so= parameter.
Variants§
Implementations§
Source§impl FileSelection
impl FileSelection
Sourcepub fn parse(value: &str) -> Result<Vec<Self>, String>
pub fn parse(value: &str) -> Result<Vec<Self>, String>
Parse a so= parameter value into a list of file selections.
Format: comma-separated entries, each either a single index or start-end range.
Example: "0,2,4-6" -> [Single(0), Single(2), Range(4, 6)]
§Errors
Returns an error if the value is empty or contains invalid entries.
Sourcepub fn to_priorities(selections: &[Self], num_files: usize) -> Vec<FilePriority>
pub fn to_priorities(selections: &[Self], num_files: usize) -> Vec<FilePriority>
Convert file selections into a FilePriority vector.
Selected files get Normal priority, unselected get Skip.
num_files is the total number of files in the torrent.
Out-of-range selections are silently ignored.
Sourcepub fn to_so_value(selections: &[Self]) -> String
pub fn to_so_value(selections: &[Self]) -> String
Serialize file selections back to a so= parameter value string.
Trait Implementations§
Source§impl Clone for FileSelection
impl Clone for FileSelection
Source§fn clone(&self) -> FileSelection
fn clone(&self) -> FileSelection
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FileSelection
impl Debug for FileSelection
Source§impl PartialEq for FileSelection
impl PartialEq for FileSelection
Source§fn eq(&self, other: &FileSelection) -> bool
fn eq(&self, other: &FileSelection) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for FileSelection
impl StructuralPartialEq for FileSelection
Auto Trait Implementations§
impl Freeze for FileSelection
impl RefUnwindSafe for FileSelection
impl Send for FileSelection
impl Sync for FileSelection
impl Unpin for FileSelection
impl UnsafeUnpin for FileSelection
impl UnwindSafe for FileSelection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more