pub struct OperationResult<T = ()> {
pub success: bool,
pub status: i32,
pub message: String,
pub result: Option<T>,
}Expand description
Outcome of an operation: success flag, business status, message, and — for
OperationResult<T> — the business payload.
OperationResult (the default T = ()) has no result member at all, so
update/delete-style endpoints can report the outcome without declaring a
one-off type. The fields are public; the constructors keep success and
status agreeing with each other.
Fields§
§success: boolWhether the operation achieved its goal.
status: i32Business status code, defined by the caller (the constructors use 0
when no explicit code is given). It is not an HTTP status: the transport
layer never reads it.
message: StringHuman-readable outcome for the caller (UI toast, CLI output, logs).
result: Option<T>The business payload; omitted from JSON when absent (the unit form, or
a failed result).
Implementations§
Source§impl<T> OperationResult<T>
impl<T> OperationResult<T>
Source§impl OperationResult<()>
impl OperationResult<()>
Sourcepub fn success(message: impl Into<String>) -> Self
pub fn success(message: impl Into<String>) -> Self
A successful result with no payload, and the default business status 0.
The JSON body is {"success":true,"status":0,"message":"..."}.
Sourcepub fn success_with_status(status: i32, message: impl Into<String>) -> Self
pub fn success_with_status(status: i32, message: impl Into<String>) -> Self
A successful result with no payload and an explicit business status.