Skip to main content

Router

Struct Router 

Source
pub struct Router { /* private fields */ }
Expand description

User-level map of project name to layout, plus the process default.

Implementations§

Source§

impl Router

Source

pub fn unrouted(default: Layout) -> Self

A router that never leaves default. Used when routing is off.

Source

pub fn load(default: Layout) -> Result<Self>

Load $VISSUE_CONFIG or the XDG file over default.

A missing default-path file is a no-op. VISSUE_NO_ROUTE set to a non-empty value other than 0 / false ignores the file.

§Errors

Returns an error if an explicit VISSUE_CONFIG path is missing, the file cannot be read or parsed, a route names an unknown layout, or a layout root is relative after expansion.

Source

pub fn from_file(default: Layout, path: &Path) -> Result<Self>

Load an explicit config file. Tests and callers that already resolved the path use this.

§Errors

Same as Self::load.

Source

pub fn default_layout(&self) -> &Layout

The process default, from --root / VISSUE_ROOT / cwd.

Source

pub fn is_routed(&self) -> bool

Whether any route is configured.

Source

pub fn route(&self, project: &str) -> ProjectRef

Resolve a caller-facing project name to a layout and on-disk directory.

Source

pub fn unique_layouts(&self) -> Vec<&Layout>

Unique layouts, default first, then named ones. Equality is (canonical root, prefix).

Source

pub fn visible_projects(&self) -> Result<Vec<ProjectRef>>

Projects an unscoped list / projects should show.

Default-layout directories whose name is an identity route key are hidden. Alias keys appear; the alias directory on the routed layout does not appear under its raw name unless that name is also a default project.

§Errors

Returns an error if a projects directory cannot be read.

Source

pub fn extra_ids_for(&self, dir: &str) -> Result<Vec<String>>

Ids already used for dir on any unique layout, so a create can refuse a suffix the twin file already holds.

§Errors

Returns an error if a twin file exists and cannot be parsed.

Source

pub fn extra_id_paths_for(&self, dir: &str) -> Vec<PathBuf>

The twin files an id reservation has to read, rather than the ids in them.

Reading the ids here and minting later is a read outside the lock that protects the write. Two creates for the same project in two roots each see the other’s file before either has written, take different locks, because the locks are per file, and can mint the same suffix. A duplicate across layouts is not a cosmetic clash: find_by_id reports DuplicateId for it, so the issue becomes unreachable by id.

So the caller hands over paths and the mint reads them under the same lock set it writes under.

Source

pub fn find_by_id(&self, id: &str) -> Result<RouteHit>

Locate one id. The longest matching route key or known project directory is tried first; then every remaining unique layout.

§Errors

Error::IssueNotFound when no layout has the id. Error::DuplicateId when two distinct layouts define it.

Source

pub fn duplicate_ids(&self) -> Result<Vec<(String, Vec<PathBuf>)>>

Ids that appear under more than one distinct unique layout.

§Errors

Returns an error if a project file cannot be read.

Trait Implementations§

Source§

impl Clone for Router

Source§

fn clone(&self) -> Router

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Router

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.