nu_protocol/
example.rs

1use crate::Value;
2#[cfg(feature = "plugin")]
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug)]
6pub struct Example<'a> {
7    pub example: &'a str,
8    pub description: &'a str,
9    pub result: Option<Value>,
10}
11
12// PluginExample is somehow like struct `Example`, but it owned a String for `example`
13// and `description` fields, because these information is fetched from plugin, a third party
14// binary, nushell have no way to construct it directly.
15#[cfg(feature = "plugin")]
16#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
17pub struct PluginExample {
18    pub example: String,
19    pub description: String,
20    pub result: Option<Value>,
21}
22
23#[cfg(feature = "plugin")]
24impl From<Example<'_>> for PluginExample {
25    fn from(value: Example) -> Self {
26        PluginExample {
27            example: value.example.into(),
28            description: value.description.into(),
29            result: value.result,
30        }
31    }
32}