Crate ommui_string_patterns [] [src]

This crate contains (de-)serialization modules that can be used for string items with serde. The (de-)serialization will fail if the required pattern is not matched. This behavior is achieved by matching against a regular expression which defines the allowed pattern.

The modules in this crate can be used by the with attribute of serde, attached to String elements.

extern crate serde_derive;

extern crate ommui_string_patterns;
extern crate serde_json;

use ommui_string_patterns::idstring_maybe_empty;

#[derive(Serialize, Deserialize, Debug)]
pub struct MyStruct {
    pub identifier: String,

fn main() {
    let json_string = r#"{ "identifier": "hello_world" }"#;
    let s: MyStruct = serde_json::from_str(json_string).unwrap();
    println!("Deserialized: {:?}", s);



For (de-)serializing ommui freetext strings.


For (de-)serializing ommui freetext strings which may be empty.


For (de-)serializing ommui id strings.


For (de-)serializing ommui id strings which may be empty.