Skip to main content

Crate sibling

Crate sibling 

Source
Expand description

The library for traversing the sibling directories. This library provides the interface for obtaining the next/previous sibling directories of a given directory by sorting with alphabetical order.

It supports various strategies for selecting the next directory, such as first, last, next, previous, random, and keep current.

§Example

The siblings of a directory are the child directories of its parent directory. Therefore, give the parent directory as the base directory, and the target directory as the current one.

use sibling::{NexterType, Nextable};
use sibling::factory::{Config, DirsFactory};

// the siblings of "testdata/basic", that is, the children of "testdata".
let config = Config::new_with_wd("testdata", false, "testdata/basic");
let dirs = DirsFactory::create_with(&config)
    .expect("Failed to create Dirs");

let next_dir = dirs.next(NexterType::Next); // Get the next sibling directory
assert_eq!(next_dir.map(|d| d.path().to_path_buf()),
           Some(std::path::PathBuf::from("testdata/demo")));

Modules§

factory

Structs§

Dir
The struct represents a directory in the traversal target set.
Dirs
Stores a list of sibling directories, the parent directory path, and the index of the current directory. This struct manages the entries of sibling directories, parent directory, and the current directory index.

Enums§

Error
The error type for sibling.
NexterType

Traits§

Nextable

Type Aliases§

Result
The result type for sibling operations.