# [−][src]Trait actix_web::dev::FromParam

    pub trait FromParam: Sized {
        type Err: ResponseError;
        fn from_param(s: &str) -> Result<Self, Self::Err>;
    }

A trait to abstract the idea of creating a new instance of a type from a path parameter.

## Associated Types

### `type Err: ResponseError`

The associated error which can be returned from parsing.

## Required Methods

### `fn from_param(s: &str) -> Result<Self, Self::Err>`

Parses a string `s` to return a value of this type.

## Implementations on Foreign Types

###

`impl FromParam for PathBuf`

[src]

Creates a `PathBuf` from a path parameter. The returned `PathBuf` is percent-decoded. If a segment is equal to "..", the previous segment (if any) is skipped.

For security purposes, if a segment meets any of the following conditions, an `Err` is returned indicating the condition met:

- Decoded segment starts with any of: `.` (except `..`), `*`
- Decoded segment ends with any of: `:`, `>`, `<`
- Decoded segment contains any of: `/`
- On Windows, decoded segment contains any of: ''
- Percent-encoding results in invalid UTF8.

As a result of these conditions, a `PathBuf` parsed from request path parameter is safe to interpolate within, or use as a suffix of, a path without additional checks.

#### `type Err = UriSegmentError`

####

`fn from_param(val: &str) -> Result<PathBuf, UriSegmentError>`

[src]

###

`impl FromParam for u8`

[src]

#### `type Err = InternalError<<u8 as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for u16`

[src]

#### `type Err = InternalError<<u16 as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for u32`

[src]

#### `type Err = InternalError<<u32 as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for u64`

[src]

#### `type Err = InternalError<<u64 as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for usize`

[src]

#### `type Err = InternalError<<usize as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for i8`

[src]

#### `type Err = InternalError<<i8 as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for i16`

[src]

#### `type Err = InternalError<<i16 as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for i32`

[src]

#### `type Err = InternalError<<i32 as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for i64`

[src]

#### `type Err = InternalError<<i64 as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for isize`

[src]

#### `type Err = InternalError<<isize as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for f32`

[src]

#### `type Err = InternalError<<f32 as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for f64`

[src]

#### `type Err = InternalError<<f64 as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for String`

[src]

#### `type Err = InternalError<<String as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for IpAddr`

[src]

#### `type Err = InternalError<<IpAddr as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for Ipv4Addr`

[src]

#### `type Err = InternalError<<Ipv4Addr as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for Ipv6Addr`

[src]

#### `type Err = InternalError<<Ipv6Addr as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for SocketAddr`

[src]

#### `type Err = InternalError<<SocketAddr as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for SocketAddrV4`

[src]

#### `type Err = InternalError<<SocketAddrV4 as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

###

`impl FromParam for SocketAddrV6`

[src]

#### `type Err = InternalError<<SocketAddrV6 as FromStr>::Err>`

####

`fn from_param(val: &str) -> Result<Self, Self::Err>`

[src]

## Implementors

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)