Skip to main content

RoutePath

Struct RoutePath 

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

Representa una ruta como un path inicial más una lista opcional de parámetros.

Modela rutas del estilo /path/to/resource?foo=bar&debug o https://example.com/path?foo=bar, pensadas para usarse en atributos HTML como href, action o src.

RoutePath no valida ni interpreta la estructura del path; simplemente concatena los parámetros de consulta sobre el valor proporcionado.

§Ejemplos

// Ruta relativa con parámetros y una *flag* sin valor.
let route = RoutePath::new("/search")
    .with_param("q", "rust")
    .with_param("page", "2")
    .with_flag("debug");
assert_eq!(route.to_string(), "/search?q=rust&page=2&debug");

// Ruta absoluta a un recurso externo.
let external = RoutePath::new("https://example.com/export").with_param("format", "csv");
assert_eq!(external.to_string(), "https://example.com/export?format=csv");

Implementations§

Source§

impl RoutePath

Source

pub fn new(path: impl Into<CowStr>) -> Self

Crea un RoutePath a partir de un path inicial.

Por ejemplo: RoutePath::new("/about").

Source

pub fn with_param( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Añade o sustituye un parámetro key=value. Si la clave ya existe, el valor se sobrescribe.

§También añade el método alter_param() generado por #[builder_fn]

Permite modificar la instancia (&mut self) con los mismos argumentos pero sin consumirla.

pub fn alter_param(&mut self, ...) -> &mut Self
Source

pub fn with_flag(self, flag: impl Into<String>) -> Self

Añade o sustituye un flag sin valor, por ejemplo ?debug.

§También añade el método alter_flag() generado por #[builder_fn]

Permite modificar la instancia (&mut self) con los mismos argumentos pero sin consumirla.

pub fn alter_flag(&mut self, ...) -> &mut Self
Source

pub fn path(&self) -> &str

Devuelve el path inicial tal y como se pasó a RoutePath::new, sin parámetros.

Trait Implementations§

Source§

impl Default for RoutePath

Source§

fn default() -> Self

Returns a RoutePath default.

Source§

impl Display for RoutePath

Source§

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

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

impl From<&'static str> for RoutePath

Source§

fn from(path: &'static str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for RoutePath

Source§

fn from(path: String) -> Self

Converts to this type from the input type.

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> AnyCast for T
where T: AnyInfo + ?Sized,

Source§

fn is<T>(&self) -> bool
where T: AnyInfo,

Comprueba si la instancia subyacente es de tipo T.
Source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AnyInfo,

Intenta hacer downcast de un objeto para obtener una referencia de tipo T.
Source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AnyInfo,

Intenta hacer downcast de un objeto para obtener una referencia mutable de tipo T.
Source§

impl<T> AnyInfo for T
where T: Any,

Source§

fn type_name(&self) -> &'static str

Devuelve el nombre totalmente cualificado del tipo.
Source§

fn short_name(&self) -> &'static str

Devuelve el nombre corto del tipo (último segmento del nombre).
Source§

fn as_any_ref(&self) -> &(dyn Any + 'static)

Devuelve una referencia a dyn Any para la conversión dinámica de tipos.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Devuelve una referencia mutable a dyn Any para la conversión dinámica de tipos.
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more