pub enum PageSelector {
Single(isize),
Range(isize, isize),
List(Vec<PageAtom>),
}Expand description
ImageMagick-style [N] / [N-M] / [A,B,…] page-selection suffix
on an input path. input.pdf[0] selects page 0; input.pdf[2-5]
selects pages 2, 3, 4, 5 (inclusive on both ends, like IM);
input.pdf[-1] selects the last page; input.pdf[0,2,4] selects a
comma-separated list (atoms may themselves be ranges, so
[0-2,5,-1] picks pages 0, 1, 2, 5, and the last page).
The single-atom variants (Single /
Range) are preserved for ergonomics — most callers
only care about the one-atom case — but every comma-separated
invocation lands as a List.
Variants§
Single(isize)
Single page index. Negative values count from the end
(-1 = last page).
Range(isize, isize)
Inclusive range start..=end. Either endpoint may be negative.
List(Vec<PageAtom>)
Comma-separated list of atoms. Order is preserved on resolve;
duplicates are NOT collapsed (IM convention — [0,0,0] writes
the same page three times). Empty list rejected at parse time.
Implementations§
Source§impl PageSelector
impl PageSelector
Sourcepub fn resolve(&self, total_pages: usize) -> Result<Vec<usize>, String>
pub fn resolve(&self, total_pages: usize) -> Result<Vec<usize>, String>
Resolve the selector to a list of zero-based page indices,
validated against total_pages. Negative indices -k resolve
to total_pages - k. Order matches the IM source order:
[0,2,4] yields [0, 2, 4]; [-1,0] yields
[total_pages-1, 0]. Duplicates (e.g. [0,0]) are preserved.
Trait Implementations§
Source§impl Clone for PageSelector
impl Clone for PageSelector
Source§impl Debug for PageSelector
impl Debug for PageSelector
impl Eq for PageSelector
Source§impl PartialEq for PageSelector
impl PartialEq for PageSelector
impl StructuralPartialEq for PageSelector
Auto Trait Implementations§
impl Freeze for PageSelector
impl RefUnwindSafe for PageSelector
impl Send for PageSelector
impl Sync for PageSelector
impl Unpin for PageSelector
impl UnsafeUnpin for PageSelector
impl UnwindSafe for PageSelector
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.