Trait rouille::input::post::DecodePostField[][src]

pub trait DecodePostField<Config>: Debug {
    fn from_field(config: Config, content: &str) -> Result<Self, PostFieldError>
    where
        Self: Sized
;
fn from_file<R>(
        config: Config,
        file: R,
        filename: Option<&str>,
        mime: &str
    ) -> Result<Self, PostFieldError>
    where
        Self: Sized,
        R: BufRead
; fn merge_multiple(self, _existing: Self) -> Result<Self, PostFieldError>
    where
        Self: Sized
, { ... }
fn not_found(_: Config) -> Result<Self, PostFieldError>
    where
        Self: Sized
, { ... } }

Must be implemented on types used with the post_input! macro.

The template parameter represents the type of a configuration object that can be passed by the user when the macro is called. If the user doesn’t pass any configuration, the expected type is ().

Required methods

fn from_field(config: Config, content: &str) -> Result<Self, PostFieldError> where
    Self: Sized
[src]

Called when a field with the given name is found in the POST input.

The value of content is what the client sent. This function should attempt to parse it into Self or return an error if it couldn’t. If Self can’t handle a field, then a PostFieldError::WrongFieldType error should be returned.

fn from_file<R>(
    config: Config,
    file: R,
    filename: Option<&str>,
    mime: &str
) -> Result<Self, PostFieldError> where
    Self: Sized,
    R: BufRead
[src]

Called when a file with the given name is found in the POST input.

The file is an object from which the body of the file can be read. The filename and mime are also arbitrary values sent directly by the client, so you shouldn’t trust them blindly.

Note: The file object can typically read directly from the socket. But don’t worry about doing something wrong, as there are protection mechanisms that will prevent you from reading too far.

This method should do something with the file (like storing it somewhere) and return a Self that will allow the user to manipulate the file that was uploaded.

If Self can’t handle a file, then a PostFieldError::WrongFieldType error should be returned.

Loading content...

Provided methods

fn merge_multiple(self, _existing: Self) -> Result<Self, PostFieldError> where
    Self: Sized
[src]

When multiple fields with the same name are found in the client’s input, rouille will build an object for each of them and then merge them with this method.

The default implementation returns UnexpectedMultipleValues.

fn not_found(_: Config) -> Result<Self, PostFieldError> where
    Self: Sized
[src]

Called when no field is found in the POST input.

The default implementation returns MissingField.

Loading content...

Implementations on Foreign Types

impl DecodePostField<()> for u8[src]

impl DecodePostField<()> for i8[src]

impl DecodePostField<()> for u16[src]

impl DecodePostField<()> for i16[src]

impl DecodePostField<()> for u32[src]

impl DecodePostField<()> for i32[src]

impl DecodePostField<()> for u64[src]

impl DecodePostField<()> for i64[src]

impl DecodePostField<()> for usize[src]

impl DecodePostField<()> for isize[src]

impl DecodePostField<()> for f32[src]

impl DecodePostField<()> for f64[src]

impl DecodePostField<()> for String[src]

impl<T, C> DecodePostField<C> for Option<T> where
    T: DecodePostField<C>, 
[src]

impl DecodePostField<()> for bool[src]

impl<T, C> DecodePostField<C> for Vec<T> where
    T: DecodePostField<C>, 
[src]

Loading content...

Implementors

impl DecodePostField<()> for BufferedFile[src]

Loading content...