pub struct CliOutput<T: Serialize> {
pub success: bool,
pub data: Option<T>,
pub error: Option<CliError>,
pub pagination: Option<PaginationMeta>,
pub platform: String,
pub command: String,
}Expand description
Unified CLI JSON output envelope.
On success, data is populated and error is None.
On failure, error is populated and data is None.
Fields with None values are omitted from serialized output.
Fields§
§success: boolWhether the command succeeded.
data: Option<T>The payload data, present only on success.
error: Option<CliError>Error details, present only on failure.
pagination: Option<PaginationMeta>分页元数据,仅列表类命令出现。
非列表命令不序列化此字段,因此其输出与本特性引入前逐字节相同。
platform: StringThe detected platform (e.g. "github").
command: StringThe command that was executed (e.g. "issue create").
Implementations§
Source§impl<T: Serialize> CliOutput<T>
impl<T: Serialize> CliOutput<T>
Sourcepub fn success(data: T, platform: &str, command: &str) -> Self
pub fn success(data: T, platform: &str, command: &str) -> Self
Create a successful output with the given data.
Sourcepub fn failure(error: CliError, platform: &str) -> Self
pub fn failure(error: CliError, platform: &str) -> Self
Create a failed output with the given error.
Sourcepub fn success_paged(
data: T,
pagination: PaginationMeta,
platform: &str,
command: &str,
) -> Self
pub fn success_paged( data: T, pagination: PaginationMeta, platform: &str, command: &str, ) -> Self
创建带分页元数据的成功输出。
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for CliOutput<T>
impl<T> RefUnwindSafe for CliOutput<T>where
Option<T>: RefUnwindSafe,
impl<T> Send for CliOutput<T>
impl<T> Sync for CliOutput<T>
impl<T> Unpin for CliOutput<T>
impl<T> UnsafeUnpin for CliOutput<T>where
Option<T>: UnsafeUnpin,
impl<T> UnwindSafe for CliOutput<T>where
Option<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more