| 1 | use serde::{Deserialize, Serialize}; |
| 2 | use uuid::Uuid; |
| 3 | |
| 4 | /// An opaque id to track command execution requests. |
| 5 | #[derive(Clone, Debug, Serialize, Deserialize)] |
| 6 | pub struct CommandExecutionRequestId(String); |
| 7 | impl CommandExecutionRequestId { |
| 8 | #[allow(clippy::new_without_default)] |
| 9 | pub fn new() -> Self { |
| 10 | Self(Uuid::new_v4().to_string()) |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | /// A set of reasons for which a command execution request might fail. |
| 15 | #[derive(Clone, Debug, Serialize, Deserialize)] |
| 16 | pub enum CommandExecutionFailureReason { |
| 17 | /// The viewer does not have sufficient permissions to run commands. |
| 18 | InsufficientPermissions, |
| 19 | |
| 20 | /// The buffer for which the command execution was requested is old. |
| 21 | /// Specifically, there is either a newer buffer or a command |
| 22 | /// is in-progress for the given buffer. |
| 23 | StaleBuffer, |
| 24 | } |