pub struct BasicMessage {
    pub output_mode: ConsoleOutputMode,
    pub action: String,
    pub result: String,
    pub status: MessageStatus,
}

Fields

output_mode: ConsoleOutputModeaction: Stringresult: Stringstatus: MessageStatus

Trait Implementations

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more

This outputs in either JSON or Text depending on the output_mode setting

use kanidm_proto::messages::*;
use std::fmt::format;
let mut msg = BasicMessage::default();
msg.action = String::from("cake_eating");
msg.result = String::from("It was amazing");
assert_eq!(msg.status, MessageStatus::Success);

let expected_result = "success - cake_eating: It was amazing";
assert_eq!(format!("{}", msg), expected_result);

msg.output_mode = ConsoleOutputMode::JSON;
let expected_result =
    "{\"action\":\"cake_eating\",\"result\":\"It was amazing\",\"status\":\"success\"}";
assert_eq!(format!("{}", msg), expected_result);
Formats the value using the given formatter. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.