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],
insensitive: bool
) -> Result<Value, ShellError>
pub fn follow_cell_path(
self,
cell_path: &[PathMember],
insensitive: bool
) -> Result<Value, ShellError>
Follow a given column path into the value: for example accessing select elements in a stream or list
pub fn follow_cell_path_not_from_user_input(
self,
cell_path: &[PathMember],
insensitive: bool
) -> Result<Value, ShellError>
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 remove_data_at_cell_path(
&mut self,
cell_path: &[PathMember]
) -> 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 is_false(&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 binary(val: impl Into<Vec<u8>>, 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 append(
&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 floor_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 bit_shl(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn bit_shr(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn bit_or(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn bit_xor(
&self,
op: Span,
rhs: &Value,
span: Span
) -> Result<Value, ShellError>
pub fn bit_and(
&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>,
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>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreAuto 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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
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,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>
fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>
fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>
fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>
fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>
fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>
fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>
fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>
fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>
fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>
fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>
fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>
fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>
fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>
fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>
fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>
fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>
fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>
fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>
fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>
fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>
fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>
fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>
fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>
fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>
fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>
fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>
fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>
fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>
fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>
fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>
fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>
fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>
fn blink<'a>(&'a self) -> BlinkDisplay<'a, Self>
fn blink<'a>(&'a self) -> BlinkDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>
fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>
fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read morefn 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,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more