pub struct RestPath { /* private fields */ }Expand description
A struct for generating standard REST API paths.
This struct provides methods to generate common REST API paths such as:
index: List all resources (e.g.,/posts).show: Show a specific resource (e.g.,/posts/{id}).create: Create a new resource (e.g.,/posts).update: Update a specific resource (e.g.,/posts/{id}).delete: Delete a specific resource (e.g.,/posts/{id}).
§Examples
use naming_utils::RestPath;
let paths = RestPath::new("posts".to_string());
assert_eq!(paths.index(), "/posts");
assert_eq!(paths.show(), "/posts/{id}");
assert_eq!(paths.create(), "/posts");
assert_eq!(paths.update(), "/posts/{id}");
assert_eq!(paths.delete(), "/posts/{id}");Implementations§
Source§impl RestPath
impl RestPath
Sourcepub fn index(&self) -> String
pub fn index(&self) -> String
Generates the path for listing all resources.
§Returns
A String representing the index path (e.g., /posts).
Sourcepub fn show(&self) -> String
pub fn show(&self) -> String
Generates the path for showing a specific resource.
§Returns
A String representing the show path (e.g., /posts/{id}).
Sourcepub fn create(&self) -> String
pub fn create(&self) -> String
Generates the path for creating a new resource.
§Returns
A String representing the create path (e.g., /posts).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RestPath
impl RefUnwindSafe for RestPath
impl Send for RestPath
impl Sync for RestPath
impl Unpin for RestPath
impl UnwindSafe for RestPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more