reactive_graph_client/client/
output_format.rs1use crate::client::result::CommandResult;
2use crate::client::result::CommandResultBuilder;
3use reactive_graph_table_model::container::TableInlineFormatSetter;
4use reactive_graph_table_model::container::TableOptions;
5
6use crate::shared::output_format::OutputFormatArgs;
7use serde::Serialize;
8use std::marker::PhantomData;
9use tabled::Tabled;
10
11pub(crate) struct OutputFormatWrapper<S: Serialize, T: Clone + Tabled + From<S> + TableInlineFormatSetter, O: TableOptions>(
12 pub Option<OutputFormatArgs>,
13 PhantomData<S>,
14 PhantomData<T>,
15 PhantomData<O>,
16);
17
18impl<S: Serialize, T: Clone + Tabled + From<S> + TableInlineFormatSetter, O: TableOptions> From<Option<OutputFormatArgs>> for OutputFormatWrapper<S, T, O> {
19 fn from(value: Option<OutputFormatArgs>) -> Self {
20 Self(value, PhantomData, PhantomData, PhantomData)
21 }
22}
23
24impl<S: Serialize + 'static, T: Clone + Tabled + From<S> + TableInlineFormatSetter + 'static, O: TableOptions + 'static> OutputFormatWrapper<S, T, O> {
25 pub(crate) fn single(self, single_object: S) -> CommandResult {
26 CommandResultBuilder::<S, T, O>::single(single_object, self.0).into_command_result()
27 }
28 pub(crate) fn collection(self, collection: Vec<S>) -> CommandResult {
29 CommandResultBuilder::<S, T, O>::collection(collection, self.0).into_command_result()
30 }
31}