Struct ApiResource

Source
pub struct ApiResource<'a, T: Display> { /* private fields */ }
Expand description

Represents a single part of of a URI path. Where arguments are optional, there are interfaces which allow this object to check if an argument is required by either this component, or entities that are related to it.

Implementations§

Source§

impl<'a, T: Display> ApiResource<'a, T>

Barebones basic implementation of an ApiResource.

use uri_resources::ApiResource;
let resource: ApiResource<'_, String> = ApiResource::new("resource");
Source

pub fn new<'b: 'a>(name: &'b str) -> Self

Create a new instance of ApiResource.

Trait Implementations§

Source§

impl<'a, T: Clone + Display> ArgedResource<T> for ApiResource<'a, T>

Source§

fn argument(&self) -> Option<&T>

Argument set on this resource.
Source§

fn required_by(&self) -> ArgRequiredBy

Determines if, and by whom, an argument set on this is required.
Source§

fn with_arg(&mut self, arg: T) -> &mut Self

Sets an argument on this resource component.
Source§

fn with_arg_required(&mut self, required: ArgRequiredBy) -> &mut Self

Sets if, and by whom, this component’s argument is required.
Source§

impl<T: Clone + Display> Clone for ApiResource<'_, T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a, T: Clone + Display> CoreResource<T> for ApiResource<'a, T>

Source§

fn name(&self) -> String

The name of the resource component. Is used as the path component on digestion.
Source§

impl<'a, T: Debug + Display> Debug for ApiResource<'a, T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a, T: Debug + Display + Clone> LinkedResource<'a, T> for ApiResource<'a, T>

Source§

fn child(&self) -> Option<&Self>

The child Resource node.
Source§

fn parent(&self) -> Option<&Self>

The parent Resource node.
Source§

fn is_child(&self) -> bool

If this is a child of another resource. Read more
Source§

fn is_root(&self) -> bool

If this is the first resource of the path. Read more
Source§

fn is_tail(&self) -> bool

If this is the last resource of the path. Read more
Source§

fn with_child(&mut self, child: &mut ApiResource<'a, T>) -> Result<Box<Self>>

Adds a child node to this resource. Fails if the child is already set.
Source§

fn with_parent(&mut self, parent: &mut ApiResource<'a, T>) -> Result<Box<Self>>

Adds the parent node to this resource. Fails if the parent is already set.
Source§

impl<'a, T: Debug + Display + Clone> PathComponent for ApiResource<'a, T>

Source§

fn as_path_component(&self) -> Result<String>

Composes this as a path component. Read more
Source§

fn compose(&self) -> Result<String>

Compose the entire heirarchy of components into one string. Read more
Source§

impl<T: Display> WeightedResource for ApiResource<'_, T>

Source§

fn weight(&self) -> f32

The sorting weight value of this.
Source§

fn with_weight(&mut self, weight: f32) -> &Self

Determines the ordering weight to be used by pre-digestion sorting.
Source§

impl<'a, T: Clone + Debug + Display> Resource<'a, T> for ApiResource<'a, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for ApiResource<'a, T>
where T: Freeze,

§

impl<'a, T> RefUnwindSafe for ApiResource<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for ApiResource<'a, T>
where T: Send,

§

impl<'a, T> Sync for ApiResource<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for ApiResource<'a, T>
where T: Unpin,

§

impl<'a, T> UnwindSafe for ApiResource<'a, T>
where T: UnwindSafe,

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.