qrock 0.2.2

Helpers for Rocket HTTP server applications.
Documentation
use rocket::form::{self, FromFormField, ValueField};

#[allow(clippy::doc_markdown)]
/// Representation of a value _SNMPv1_ Community string.
///
/// Allowed characters are:
/// - English uppercase characters (A - Z)
/// - English lowercase characters (a - z)
/// - Base 10 digits (0 - 9)
/// - Special characters: `- . # % ^ * ( ) - _ + = { } [ ] | : ; , !`
///
/// The maximum length is 31 characters.
#[derive(Debug)]
pub struct Community<'r>(pub &'r str);

#[rocket::async_trait]
impl<'r> FromFormField<'r> for Community<'r> {
  fn from_value(field: ValueField<'r>) -> form::Result<'r, Self> {
    let s = field.value;
    Ok(Community(s))
  }
}

// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :