Skip to content

Commit

Permalink
General project cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
CathalMullan committed Jan 6, 2025
1 parent 12308ad commit 4d3ef06
Show file tree
Hide file tree
Showing 20 changed files with 417 additions and 402 deletions.
8 changes: 4 additions & 4 deletions BENCHMARKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Check out our [codspeed results](https://codspeed.io/DuskSystems/wayfind/benchma

For all benchmarks, we convert any extracted parameters to strings.

ALl routers provide a way to get parameters as strings, but some delay the actual decoding until post-search.
All routers provide a way to get parameters as strings, but some delay the actual decoding until post-search.

| Library | Percent Decoding | String Parameters |
|:-----------------|:----------------:|:-----------------:|
Expand All @@ -21,7 +21,7 @@ ALl routers provide a way to get parameters as strings, but some delay the actua
| routefinder | no | yes |
| xitca-router | no | yes |

### `matchit` inspired benches
## `matchit` inspired benches

In a router of 130 templates, benchmark matching 4 paths.

Expand All @@ -36,7 +36,7 @@ In a router of 130 templates, benchmark matching 4 paths.
| routefinder | 5.7907 µs | 67 | 5.056 KB | 67 | 5.056 KB |
| actix-router | 19.619 µs | 214 | 13.96 KB | 214 | 13.96 KB |

### `path-tree` inspired benches
## `path-tree` inspired benches

In a router of 320 templates, benchmark matching 80 paths.

Expand All @@ -51,6 +51,6 @@ In a router of 320 templates, benchmark matching 80 paths.
| routefinder | 80.345 µs | 525 | 49.66 KB | 525 | 49.66 KB |
| actix-router | 174.04 µs | 2201 | 130.1 KB | 2201 | 130.1 KB |

### `wayfind` benches
## `wayfind` benches

TODO
140 changes: 0 additions & 140 deletions src/display.rs

This file was deleted.

3 changes: 0 additions & 3 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ pub use constraint::ConstraintError;
pub mod delete;
pub use delete::DeleteError;

pub mod encoding;
pub use encoding::EncodingError;

pub mod insert;
pub use insert::InsertError;

Expand Down
6 changes: 3 additions & 3 deletions src/errors/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum DeleteError {
/// use wayfind::errors::DeleteError;
///
/// let error = DeleteError::NotFound {
/// template: "/not_found".to_string(),
/// template: "/not_found".to_owned(),
/// };
///
/// let display = "
Expand All @@ -42,8 +42,8 @@ pub enum DeleteError {
/// use wayfind::errors::DeleteError;
///
/// let error = DeleteError::Mismatch {
/// template: "/users/{id}/".to_string(),
/// inserted: "/users/{id}(/)".to_string(),
/// template: "/users/{id}/".to_owned(),
/// inserted: "/users/{id}(/)".to_owned(),
/// };
///
/// let display = "
Expand Down
53 changes: 0 additions & 53 deletions src/errors/encoding.rs

This file was deleted.

62 changes: 58 additions & 4 deletions src/errors/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,40 @@ pub enum InsertError {
/// A [`TemplateError`] that occurred during the insert operation.
Template(TemplateError),

/// FIXME
Conflict,
/// One or more conflicting routes found during the insert.
///
/// # Examples
///
/// ```rust
/// use wayfind::errors::InsertError;
///
/// let error = InsertError::Conflict {
/// template: "(/a(/b))(/x/y)".to_owned(),
/// conflicts: vec![
/// "/a(/b)".to_owned(),
/// "/x/y".to_owned(),
/// ]
/// };
///
/// let display = "
/// conflicts detected
///
/// Template: (/a(/b))(/x/y)
/// Conflicts:
/// - /a(/b)
/// - /x/y
///
/// The template cannot be inserted as it conflict with one or more existing routes
/// ";
///
/// assert_eq!(error.to_string(), display.trim());
/// ```
Conflict {
/// The template being inserted.
template: String,
/// List of existing templates that conflict.
conflicts: Vec<String>,
},

/// The constraint specified in the template is not recognized by the router.
///
Expand All @@ -19,7 +51,7 @@ pub enum InsertError {
/// use wayfind::errors::InsertError;
///
/// let error = InsertError::UnknownConstraint {
/// constraint: "unknown_constraint".to_string(),
/// constraint: "unknown_constraint".to_owned(),
/// };
///
/// let display = "
Expand All @@ -44,7 +76,29 @@ impl Display for InsertError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Template(error) => error.fmt(f),
Self::Conflict => write!(f, "CONFLICT"),
Self::Conflict {
template,
conflicts,
} => {
let conflicts = conflicts
.iter()
.map(|conflict| format!(" - {conflict}"))
.collect::<Vec<_>>()
.join("\n")
.trim_end()
.to_owned();

write!(
f,
r"conflicts detected
Template: {template}
Conflicts:
{conflicts}
The template cannot be inserted as it conflict with one or more existing routes"
)
}
Self::UnknownConstraint { constraint } => write!(
f,
r"unknown constraint
Expand Down
Loading

0 comments on commit 4d3ef06

Please sign in to comment.