Struct fsort::file_collection::DynamicCollection [] [src]

pub struct DynamicCollection { /* fields omitted */ }

A sorted collection of files with changeable criterion.

Methods

impl DynamicCollection
[src]

Creates a new sorted collection with a specific criterion.

Examples

use fsort::criterion::FileName;
use fsort::file_collection::DynamicCollection;

let collection = DynamicCollection::new::<FileName>();

Changes the sorting criterion.

Examples

use std::fs::File;
use std::path::PathBuf;
use fsort::criterion::{FileName, FileSize};
use fsort::file_collection::{FileCollection, DynamicCollection};

// Creates temporal files
let mut s1 = std::env::temp_dir();
let mut s2 = std::env::temp_dir();
s1.push("S1.tmp");
s2.push("S2.tmp");
File::create(&s1).unwrap().set_len(10);
File::create(&s2).unwrap().set_len(5);

// Inserts files into collection
let mut collection = DynamicCollection::new::<FileName>();
collection.add_file(&s2);
collection.add_file(&s1);

let mut iter_name = collection.path_iter();
assert_eq!(s1, iter_name.next().unwrap());
assert_eq!(s2, iter_name.next().unwrap());
assert_eq!(None, iter_name.next());

collection.set_criterion::<FileSize>();
let mut iter_size = collection.path_iter();
assert_eq!(s2, iter_size.next().unwrap());
assert_eq!(s1, iter_size.next().unwrap());
assert_eq!(None, iter_size.next());

Trait Implementations

impl FileCollection for DynamicCollection
[src]

Adds a file to the collection. # Examples See DynamicCollection::set_criterion Read more

Adds all files of a directory to the collection.

Sets the current order of the collection.

Returns the current order of the collection.

Returns an iterator about all the (sorted) paths in the collection according to the order. # Examples See DynamicCollection::set_criterion Read more

impl IntoIterator for DynamicCollection
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more