Skip to main content

muse_code_sdk/msp/method/lifecycle/
session_leave.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use crate::msp::command::CommandAckStatus;
4use serde::Deserialize;
5use serde::Serialize;
6
7/// `session/leave` params.
8#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct SessionLeaveParams {
11    /// Client-minted UUIDv7 command identity.
12    pub command_id: String,
13    /// The exact loaded session whose ownership is to be released.
14    pub session_id: String,
15    /// Explicitly cancel unfinished work before leaving. Omitted is `false`.
16    #[serde(default, skip_serializing_if = "Option::is_none")]
17    pub stop: Option<bool>,
18}
19
20/// The admission-only `session/leave` result.
21#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
22#[serde(rename_all = "camelCase")]
23#[non_exhaustive]
24pub struct SessionLeaveResult {
25    pub command_id: String,
26    pub status: CommandAckStatus,
27}
28
29/// Current producer outcomes for `session/leaveCompleted`; receiver-open.
30#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
31#[serde(transparent)]
32#[non_exhaustive]
33pub struct SessionLeaveOutcome(pub String);
34
35impl SessionLeaveOutcome {
36    pub const RELEASED: &'static str = "released";
37    pub const FAILED: &'static str = "failed";
38}
39
40/// Current producer failure reasons for `session/leaveCompleted`;
41/// receiver-open for additive future reasons.
42#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
43#[serde(transparent)]
44#[non_exhaustive]
45pub struct SessionLeaveFailureReason(pub String);
46
47impl SessionLeaveFailureReason {
48    pub const TIMEOUT: &'static str = "timeout";
49    pub const RESPONSE_UNDELIVERED: &'static str = "responseUndelivered";
50    pub const PERSISTENCE_FAILED: &'static str = "persistenceFailed";
51    pub const RUNTIME_FAILED: &'static str = "runtimeFailed";
52    pub const ABANDONED: &'static str = "abandoned";
53}
54
55/// Params of the protected, non-view leave terminal notification.
56#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
57#[serde(rename_all = "camelCase")]
58#[non_exhaustive]
59pub struct SessionLeaveCompletedParams {
60    pub session_id: String,
61    pub command_id: String,
62    pub outcome: SessionLeaveOutcome,
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub reason: Option<SessionLeaveFailureReason>,
65    #[serde(skip_serializing_if = "Option::is_none")]
66    pub view_cursor: Option<String>,
67}