Enum nu_protocol::Value
source · [−]pub enum Value {
Show 16 variants
Bool {
val: bool,
span: Span,
},
Int {
val: i64,
span: Span,
},
Float {
val: f64,
span: Span,
},
Filesize {
val: i64,
span: Span,
},
Duration {
val: i64,
span: Span,
},
Date {
val: DateTime<FixedOffset>,
span: Span,
},
Range {
val: Box<Range>,
span: Span,
},
String {
val: String,
span: Span,
},
Record {
cols: Vec<String>,
vals: Vec<Value>,
span: Span,
},
List {
vals: Vec<Value>,
span: Span,
},
Block {
val: BlockId,
captures: HashMap<VarId, Value>,
span: Span,
},
Nothing {
span: Span,
},
Error {
error: ShellError,
},
Binary {
val: Vec<u8>,
span: Span,
},
CellPath {
val: CellPath,
span: Span,
},
CustomValue {
val: Box<dyn CustomValue>,
span: Span,
},
}
Expand description
Core structured values that pass through the pipeline in Nushell.
Variants
Bool
Int
Float
Filesize
Duration
Date
Range
String
Record
List
Block
Nothing
Fields
span: Span
Error
Fields
error: ShellError
Binary
CellPath
CustomValue
Implementations
sourceimpl Value
impl Value
pub fn into_config(self) -> Result<Config, ShellError>
sourceimpl Value
impl Value
pub fn as_f64(&self) -> Result<f64, ShellError>
pub fn as_i64(&self) -> Result<i64, ShellError>
sourceimpl Value
impl Value
sourcepub fn as_string(&self) -> Result<String, ShellError>
pub fn as_string(&self) -> Result<String, ShellError>
Converts into string values that can be changed into string natively
pub fn as_spanned_string(&self) -> Result<Spanned<String>, ShellError>
pub fn as_path(&self) -> Result<PathBuf, ShellError>
pub fn as_block(&self) -> Result<BlockId, ShellError>
pub fn as_binary(&self) -> Result<&[u8], ShellError>
pub fn as_record(&self) -> Result<(&[String], &[Value]), ShellError>
pub fn as_list(&self) -> Result<&[Value], ShellError>
pub fn as_bool(&self) -> Result<bool, ShellError>
pub fn as_float(&self) -> Result<f64, ShellError>
pub fn as_integer(&self) -> Result<i64, ShellError>
sourcepub fn span(&self) -> Result<Span, ShellError>
pub fn span(&self) -> Result<Span, ShellError>
Get the span for the current value
pub fn get_data_by_key(&self, name: &str) -> Option<Value>
sourcepub fn into_string(&self, separator: &str, config: &Config) -> String
pub fn into_string(&self, separator: &str, config: &Config) -> String
Convert Value into string. Note that Streams will be consumed.
sourcepub fn into_abbreviated_string(&self, config: &Config) -> String
pub fn into_abbreviated_string(&self, config: &Config) -> String
Convert Value into string. Note that Streams will be consumed.
sourcepub fn debug_value(&self) -> String
pub fn debug_value(&self) -> String
Convert Value into a debug string
sourcepub fn debug_string(&self, separator: &str, config: &Config) -> String
pub fn debug_string(&self, separator: &str, config: &Config) -> String
Convert Value into string. Note that Streams will be consumed.
pub fn is_nothing(&self) -> bool
sourcepub fn follow_cell_path(
self,
cell_path: &[PathMember]
) -> Result<Value, ShellError>
pub fn follow_cell_path(
self,
cell_path: &[PathMember]
) -> Result<Value, ShellError>
Follow a given column path into the value: for example accessing select elements in a stream or list
sourcepub fn upsert_cell_path(
&mut self,
cell_path: &[PathMember],
callback: Box<dyn FnOnce(&Value) -> Value>
) -> Result<(), ShellError>
pub fn upsert_cell_path(
&mut self,
cell_path: &[PathMember],
callback: Box<dyn FnOnce(&Value) -> Value>
) -> Result<(), ShellError>
Follow a given column path into the value: for example accessing select elements in a stream or list
pub fn upsert_data_at_cell_path(
&mut self,
cell_path: &[PathMember],
new_val: Value
) -> Result<(), ShellError>
sourcepub fn update_cell_path(
&mut self,
cell_path: &[PathMember],
callback: Box<dyn FnOnce(&Value) -> Value>
) -> Result<(), ShellError>
pub fn update_cell_path(
&mut self,
cell_path: &[PathMember],
callback: Box<dyn FnOnce(&Value) -> Value>
) -> Result<(), ShellError>
Follow a given column path into the value: for example accessing select elements in a stream or list
pub fn update_data_at_cell_path(
&mut self,
cell_path: &[PathMember],
new_val: Value
) -> Result<(), ShellError>
pub fn insert_data_at_cell_path(
&mut self,
cell_path: &[PathMember],
new_val: Value
) -> Result<(), ShellError>
pub fn is_true(&self) -> bool
pub fn columns(&self) -> Vec<String>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn string(val: impl Into<String>, span: Span) -> Value
pub fn int(val: i64, span: Span) -> Value
pub fn float(val: f64, span: Span) -> Value
pub fn boolean(val: bool, span: Span) -> Value
sourcepub fn test_string(s: impl Into<String>) -> Value
pub fn test_string(s: impl Into<String>) -> Value
Note: Only use this for test data, not live data, as it will point into unknown source when used in errors.
sourcepub fn test_int(val: i64) -> Value
pub fn test_int(val: i64) -> Value
Note: Only use this for test data, not live data, as it will point into unknown source when used in errors.
sourcepub fn test_float(val: f64) -> Value
pub fn test_float(val: f64) -> Value
Note: Only use this for test data, not live data, as it will point into unknown source when used in errors.
sourcepub fn test_bool(val: bool) -> Value
pub fn test_bool(val: bool) -> Value
Note: Only use this for test data, not live data, as it will point into unknown source when used in errors.
sourcepub fn test_filesize(val: i64) -> Value
pub fn test_filesize(val: i64) -> Value
Note: Only use this for test data, not live data, as it will point into unknown source when used in errors.
sourcepub fn test_nothing() -> Value
pub fn test_nothing() -> Value
Note: Only use this for test data, not live data, as it will point into unknown source when used in errors.
sourceimpl Value
impl Value
pub fn add(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn sub(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn mul(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn div(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn lt(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError>
pub fn lte(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn gt(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError>
pub fn gte(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn eq(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError>
pub fn ne(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError>
pub fn in(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError>
pub fn not_in(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn regex_match(
&self,
op: Span,
rhs: &Value,
invert: bool,
span: Span
) -> Result<Value, ShellError>
pub fn starts_with(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn ends_with(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn modulo(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn and(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn or(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError>
pub fn pow(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<Spanned<HashMap<String, Value, RandomState>>> for Value
impl From<Spanned<HashMap<String, Value, RandomState>>> for Value
Create a Value::Record from a spanned hashmap
sourceimpl From<Spanned<IndexMap<String, Value, RandomState>>> for Value
impl From<Spanned<IndexMap<String, Value, RandomState>>> for Value
Create a Value::Record from a spanned indexmap
sourceimpl FromValue for Value
impl FromValue for Value
fn from_value(v: &Value) -> Result<Self, ShellError>
sourceimpl PartialOrd<Value> for Value
impl PartialOrd<Value> for Value
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
Auto Trait Implementations
impl !RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl !UnwindSafe for Value
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<D> OwoColorize for D
impl<D> OwoColorize for D
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self> where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self> where
C: Color,
Set the foreground color generically Read more
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self> where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self> where
C: Color,
Set the background color generically. Read more
fn black(&'a self) -> FgColorDisplay<'a, Black, Self>
fn black(&'a self) -> FgColorDisplay<'a, Black, Self>
Change the foreground color to black
fn on_black(&'a self) -> BgColorDisplay<'a, Black, Self>
fn on_black(&'a self) -> BgColorDisplay<'a, Black, Self>
Change the background color to black
fn red(&'a self) -> FgColorDisplay<'a, Red, Self>
fn red(&'a self) -> FgColorDisplay<'a, Red, Self>
Change the foreground color to red
fn on_red(&'a self) -> BgColorDisplay<'a, Red, Self>
fn on_red(&'a self) -> BgColorDisplay<'a, Red, Self>
Change the background color to red
fn green(&'a self) -> FgColorDisplay<'a, Green, Self>
fn green(&'a self) -> FgColorDisplay<'a, Green, Self>
Change the foreground color to green
fn on_green(&'a self) -> BgColorDisplay<'a, Green, Self>
fn on_green(&'a self) -> BgColorDisplay<'a, Green, Self>
Change the background color to green
fn yellow(&'a self) -> FgColorDisplay<'a, Yellow, Self>
fn yellow(&'a self) -> FgColorDisplay<'a, Yellow, Self>
Change the foreground color to yellow
fn on_yellow(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow(&'a self) -> BgColorDisplay<'a, Yellow, Self>
Change the background color to yellow
fn blue(&'a self) -> FgColorDisplay<'a, Blue, Self>
fn blue(&'a self) -> FgColorDisplay<'a, Blue, Self>
Change the foreground color to blue
fn on_blue(&'a self) -> BgColorDisplay<'a, Blue, Self>
fn on_blue(&'a self) -> BgColorDisplay<'a, Blue, Self>
Change the background color to blue
fn magenta(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta(&'a self) -> FgColorDisplay<'a, Magenta, Self>
Change the foreground color to magenta
fn on_magenta(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta(&'a self) -> BgColorDisplay<'a, Magenta, Self>
Change the background color to magenta
fn purple(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn purple(&'a self) -> FgColorDisplay<'a, Magenta, Self>
Change the foreground color to purple
fn on_purple(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple(&'a self) -> BgColorDisplay<'a, Magenta, Self>
Change the background color to purple
fn cyan(&'a self) -> FgColorDisplay<'a, Cyan, Self>
fn cyan(&'a self) -> FgColorDisplay<'a, Cyan, Self>
Change the foreground color to cyan
fn on_cyan(&'a self) -> BgColorDisplay<'a, Cyan, Self>
fn on_cyan(&'a self) -> BgColorDisplay<'a, Cyan, Self>
Change the background color to cyan
fn white(&'a self) -> FgColorDisplay<'a, White, Self>
fn white(&'a self) -> FgColorDisplay<'a, White, Self>
Change the foreground color to white
fn on_white(&'a self) -> BgColorDisplay<'a, White, Self>
fn on_white(&'a self) -> BgColorDisplay<'a, White, Self>
Change the background color to white
fn default_color(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color(&'a self) -> FgColorDisplay<'a, Default, Self>
Change the foreground color to the terminal default
fn on_default_color(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color(&'a self) -> BgColorDisplay<'a, Default, Self>
Change the background color to the terminal default
fn bright_black(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
Change the foreground color to bright black
fn on_bright_black(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
Change the background color to bright black
fn bright_red(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
Change the foreground color to bright red
fn on_bright_red(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
Change the background color to bright red
fn bright_green(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
Change the foreground color to bright green
fn on_bright_green(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
Change the background color to bright green
fn bright_yellow(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
Change the foreground color to bright yellow
fn on_bright_yellow(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
Change the background color to bright yellow
fn bright_blue(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
Change the foreground color to bright blue
fn on_bright_blue(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
Change the background color to bright blue
fn bright_magenta(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
Change the foreground color to bright magenta
fn on_bright_magenta(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
Change the background color to bright magenta
fn bright_purple(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
Change the foreground color to bright purple
fn on_bright_purple(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
Change the background color to bright purple
fn bright_cyan(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
Change the foreground color to bright cyan
fn on_bright_cyan(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
Change the background color to bright cyan
fn bright_white(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
Change the foreground color to bright white
fn on_bright_white(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
Change the background color to bright white
fn bold(&'a self) -> BoldDisplay<'a, Self>
fn bold(&'a self) -> BoldDisplay<'a, Self>
Make the text bold
fn dimmed(&'a self) -> DimDisplay<'a, Self>
fn dimmed(&'a self) -> DimDisplay<'a, Self>
Make the text dim
fn italic(&'a self) -> ItalicDisplay<'a, Self>
fn italic(&'a self) -> ItalicDisplay<'a, Self>
Make the text italicized
fn underline(&'a self) -> UnderlineDisplay<'a, Self>
fn underline(&'a self) -> UnderlineDisplay<'a, Self>
Make the text italicized
fn blink(&'a self) -> BlinkDisplay<'a, Self>
fn blink(&'a self) -> BlinkDisplay<'a, Self>
Make the text blink
fn blink_fast(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast(&'a self) -> BlinkFastDisplay<'a, Self>
Make the text blink (but fast!)
fn reversed(&'a self) -> ReversedDisplay<'a, Self>
fn reversed(&'a self) -> ReversedDisplay<'a, Self>
Swap the foreground and background colors
Hide the text
fn strikethrough(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough(&'a self) -> StrikeThroughDisplay<'a, Self>
Cross out the text
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self> where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self> where
Color: DynColor,
Set the foreground color at runtime. Only use if you do not know which color will be used at
compile-time. If the color is constant, use either OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read more
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self> where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self> where
Color: DynColor,
Set the background color at runtime. Only use if you do not know what color to use at
compile-time. If the color is constant, use either OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more
fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Set the foreground color to a specific RGB value.
fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Set the background color to a specific RGB value.
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Sets the foreground color to an RGB value.
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Sets the background color to an RGB value.
sourceimpl<T> Serialize for T where
T: Serialize + ?Sized,
impl<T> Serialize for T where
T: Serialize + ?Sized,
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more