Struct fsort::file_collection::StaticCollection [] [src]

pub struct StaticCollection<C: Criterion> { /* fields omitted */ }

A sorted collection of files with fixed criterion.

Methods

impl<C: Criterion> StaticCollection<C>
[src]

Creates a new sorted collection with a specific criterion.

Examples

use fsort::criterion::FileName;
use fsort::file_collection::StaticCollection;

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

Returns an iterator over the sorted files in the collection according to the criterion.

Examples

use std::fs::File;
use std::path::PathBuf;
use fsort::criterion::FileName;
use fsort::file_collection::StaticCollection;
use fsort::file_collection::FileCollection;

let mut i1 = std::env::temp_dir();
let mut i2 = std::env::temp_dir();
i1.push("I1.tmp");
i2.push("I2.tmp");
File::create(&i1).unwrap();
File::create(&i2).unwrap();

// Inserts files into collection
let mut collection = StaticCollection::<FileName>::new();
collection.add_file(&i2);
collection.add_file(&i1);

let mut iter = collection.iter();
assert_eq!(i1, iter.next().unwrap().path);
assert_eq!(i2, iter.next().unwrap().path);
assert_eq!(None, iter.next());

Trait Implementations

impl<C: Criterion> FileCollection for StaticCollection<C>
[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<C: Criterion> IntoIterator for StaticCollection<C>
[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

impl<C: Criterion> Default for StaticCollection<C>
[src]

Returns the "default value" for a type. Read more