pub struct RapidPath<T>(_);Expand description
Extract typed data from request path segments.
Use PathConfig to configure extraction option.
Unlike, HttpRequest::match_info, this extractor will fully percent-decode dynamic segments,
including /, %, and +.
Examples
use actix_web::{get, web};
// extract path info from "/{name}/{count}/index.html" into tuple
// {name} - deserialize a String
// {count} - deserialize a u32
#[get("/{name}/{count}/index.html")]
async fn index(path: web::Path<(String, u32)>) -> String {
let (name, count) = path.into_inner();
format!("Welcome {}! {}", name, count)
}Path segments also can be deserialized into any type that implements serde::Deserialize.
Path segment labels will be matched with struct field names.
use actix_web::{get, web};
use serde::Deserialize;
#[derive(Deserialize)]
struct Info {
name: String,
}
// extract `Info` from a path using serde
#[get("/{name}")]
async fn index(info: web::Path<Info>) -> String {
format!("Welcome {}!", info.name)
}Implementations§
source§impl<T> Path<T>
impl<T> Path<T>
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Unwrap into inner T value.
Trait Implementations§
source§impl<T> FromRequest for Path<T>where
T: DeserializeOwned,
impl<T> FromRequest for Path<T>where T: DeserializeOwned,
See here for example of usage as an extractor.
§type Future = Ready<Result<Path<T>, <Path<T> as FromRequest>::Error>>
type Future = Ready<Result<Path<T>, <Path<T> as FromRequest>::Error>>
Self. Read moresource§fn from_request(
req: &HttpRequest,
_: &mut Payload<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>
) -> <Path<T> as FromRequest>::Future
fn from_request( req: &HttpRequest, _: &mut Payload<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>> ) -> <Path<T> as FromRequest>::Future
Self from request parts asynchronously.source§impl<T> Ord for Path<T>where
T: Ord,
impl<T> Ord for Path<T>where T: Ord,
source§impl<T> PartialEq<Path<T>> for Path<T>where
T: PartialEq<T>,
impl<T> PartialEq<Path<T>> for Path<T>where T: PartialEq<T>,
source§impl<T> PartialOrd<Path<T>> for Path<T>where
T: PartialOrd<T>,
impl<T> PartialOrd<Path<T>> for Path<T>where T: PartialOrd<T>,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl<T> Eq for Path<T>where T: Eq,
impl<T> StructuralEq for Path<T>
impl<T> StructuralPartialEq for Path<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Path<T>where T: RefUnwindSafe,
impl<T> Send for Path<T>where T: Send,
impl<T> Sync for Path<T>where T: Sync,
impl<T> Unpin for Path<T>where T: Unpin,
impl<T> UnwindSafe for Path<T>where T: UnwindSafe,
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
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> FromFd for Twhere
T: From<OwnedFd>,
impl<T> FromFd for Twhere T: From<OwnedFd>,
§impl<T> FromFilelike for Twhere
T: From<OwnedFd>,
impl<T> FromFilelike for Twhere T: From<OwnedFd>,
§fn from_filelike(owned: OwnedFd) -> T
fn from_filelike(owned: OwnedFd) -> T
Self from the given filelike object. Read more§fn from_into_filelike<Owned>(owned: Owned) -> Twhere
Owned: IntoFilelike,
fn from_into_filelike<Owned>(owned: Owned) -> Twhere Owned: IntoFilelike,
Self from the given filelike object
converted from into_owned. Read more§impl<T> FromSocketlike for Twhere
T: From<OwnedFd>,
impl<T> FromSocketlike for Twhere T: From<OwnedFd>,
§fn from_socketlike(owned: OwnedFd) -> T
fn from_socketlike(owned: OwnedFd) -> T
Self from the given socketlike object.§fn from_into_socketlike<Owned>(owned: Owned) -> Twhere
Owned: IntoSocketlike,
fn from_into_socketlike<Owned>(owned: Owned) -> Twhere Owned: IntoSocketlike,
Self from the given socketlike object
converted from into_owned.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T, P> Resource for Twhere
T: DerefMut<Target = Path<P>>,
P: ResourcePath,
impl<T, P> Resource for Twhere T: DerefMut<Target = Path<P>>, P: ResourcePath,
fn resource_path(&mut self) -> &mut Path<<T as Resource>::Path>
§impl<T, I> Stylize<T> for Iwhere
I: Into<Styled<T>>,
impl<T, I> Stylize<T> for Iwhere I: Into<Styled<T>>,
fn black(self) -> Styled<T>
fn dark_grey(self) -> Styled<T>
fn light_red(self) -> Styled<T>
fn red(self) -> Styled<T>
fn light_green(self) -> Styled<T>
fn green(self) -> Styled<T>
fn light_yellow(self) -> Styled<T>
fn yellow(self) -> Styled<T>
fn light_blue(self) -> Styled<T>
fn blue(self) -> Styled<T>
fn light_magenta(self) -> Styled<T>
fn magenta(self) -> Styled<T>
fn light_cyan(self) -> Styled<T>
fn cyan(self) -> Styled<T>
fn white(self) -> Styled<T>
fn grey(self) -> Styled<T>
fn rgb(self, r: u8, g: u8, b: u8) -> Styled<T>
fn ansi(self, ansi: u8) -> Styled<T>
fn on_black(self) -> Styled<T>
fn on_dark_grey(self) -> Styled<T>
fn on_light_red(self) -> Styled<T>
fn on_red(self) -> Styled<T>
fn on_light_green(self) -> Styled<T>
fn on_green(self) -> Styled<T>
fn on_light_yellow(self) -> Styled<T>
fn on_yellow(self) -> Styled<T>
fn on_light_blue(self) -> Styled<T>
fn on_blue(self) -> Styled<T>
fn on_light_magenta(self) -> Styled<T>
fn on_magenta(self) -> Styled<T>
fn on_light_cyan(self) -> Styled<T>
fn on_cyan(self) -> Styled<T>
fn on_white(self) -> Styled<T>
fn on_grey(self) -> Styled<T>
fn on_rgb(self, r: u8, g: u8, b: u8) -> Styled<T>
fn on_ansi(self, ansi: u8) -> Styled<T>
fn bold(self) -> Styled<T>
fn underlined(self) -> Styled<T>
fn reverse(self) -> Styled<T>
fn dim(self) -> Styled<T>
fn italic(self) -> Styled<T>
fn slow_blink(self) -> Styled<T>
fn rapid_blink(self) -> Styled<T>
fn crossed_out(self) -> Styled<T>
§impl<T> Widget for Twhere
T: Deref<Target = str> + ?Sized,
impl<T> Widget for Twhere T: Deref<Target = str> + ?Sized,
§fn render<B>(
&mut self,
layout: &mut Layout,
backend: &mut B
) -> Result<(), Error>where
B: Backend,
fn render<B>( &mut self, layout: &mut Layout, backend: &mut B ) -> Result<(), Error>where B: Backend,
Does not allow multi-line strings. If the string requires more than a single line, it adds cuts it short and adds ‘…’ to the end.
If a multi-line string is required, use the Text widget.
§fn height(&mut self, layout: &mut Layout) -> u16
fn height(&mut self, layout: &mut Layout) -> u16
Does not allow multi-line strings.
If a multi-line string is required, use the Text widget.
§fn cursor_pos(&mut self, layout: Layout) -> (u16, u16)
fn cursor_pos(&mut self, layout: Layout) -> (u16, u16)
Returns the location of the first character
§fn handle_key(&mut self, _: KeyEvent) -> bool
fn handle_key(&mut self, _: KeyEvent) -> bool
This widget does not handle any events