/**
 * Format the incoming (JSON-formatted) event into an Event struct.
 */
Format the incoming (JSON-formatted) event into an Event struct.
Format the incoming ( JSON - formatted ) event into an Event struct .
pub fn format_event(request: &CsmlRequest) -> Result<Event, EngineError> {
    let step_limit = request.step_limit;
    let json_event = json!(request);
    let content_type = match json_event["payload"]["content_type"].as_str() {
        Some(content_type) => content_type.to_string(),
        None => {
            return Err(EngineError::Interpreter(
                "no content_type in event payload".to_owned(),
            ))
        }
    };
    let content = json_event["payload"]["content"].to_owned();
    let content_value = get_event_content(&content_type, &content)?;
    Ok(Event {
        content_type,
        content_value,
        content,
        ttl_duration: json_event["ttl_duration"].as_i64(),
        low_data_mode: json_event["low_data_mode"].as_bool(),
        step_limit,
        secure: json_event["payload"]["secure"].as_bool().unwrap_or(false),
    })
}
pub fn format_event ( request : & CsmlRequest ) -> Result < Event , EngineError > { let step_limit = request . step_limit ; let json_event = json ! ( request ) ; let content_type = match json_event [ " " ] [ " " ] . as_str ( ) { Some ( content_type ) => content_type . to_string ( ) , None => { return Err ( EngineError :: Interpreter ( " " . to_owned ( ) , ) ) } } ; let content = json_event [ " " ] [ " " ] . to_owned ( ) ; let content_value = get_event_content ( & content_type , & content ) ? ; Ok ( Event { content_type , content_value , content , ttl_duration : json_event [ " " ] . as_i64 ( ) , low_data_mode : json_event [ " " ] . as_bool ( ) , step_limit , secure : json_event [ " " ] [ " " ] . as_bool ( ) . unwrap_or ( false ) , } ) }
Format the incoming (JSON-formatted) event into an Event struct.
Format the incoming ( JSON - formatted ) event into an Event struct .
request
&CsmlRequest