Enum nu_protocol::Value
source · pub enum Value {
Show 19 variants
Bool {
val: bool,
internal_span: Span,
},
Int {
val: i64,
internal_span: Span,
},
Float {
val: f64,
internal_span: Span,
},
Filesize {
val: i64,
internal_span: Span,
},
Duration {
val: i64,
internal_span: Span,
},
Date {
val: DateTime<FixedOffset>,
internal_span: Span,
},
Range {
val: Box<Range>,
internal_span: Span,
},
String {
val: String,
internal_span: Span,
},
Record {
val: Record,
internal_span: Span,
},
List {
vals: Vec<Value>,
internal_span: Span,
},
Block {
val: BlockId,
internal_span: Span,
},
Closure {
val: BlockId,
captures: HashMap<VarId, Value>,
internal_span: Span,
},
Nothing {
internal_span: Span,
},
Error {
error: Box<ShellError>,
internal_span: Span,
},
Binary {
val: Vec<u8>,
internal_span: Span,
},
CellPath {
val: CellPath,
internal_span: Span,
},
CustomValue {
val: Box<dyn CustomValue>,
internal_span: Span,
},
LazyRecord {
val: Box<dyn for<'a> LazyRecord<'a>>,
internal_span: Span,
},
MatchPattern {
val: Box<MatchPattern>,
internal_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
Closure
Nothing
Error
Binary
CellPath
CustomValue
LazyRecord
MatchPattern
Implementations§
source§impl Value
impl Value
pub fn into_config(&mut self, config: &Config) -> (Config, Option<ShellError>)
source§impl Value
impl Value
pub fn as_f64(&self) -> Result<f64, ShellError>
pub fn as_i64(&self) -> Result<i64, ShellError>
source§impl Value
impl Value
pub fn as_bool(&self) -> Result<bool, ShellError>
pub fn as_int(&self) -> Result<i64, ShellError>
pub fn as_float(&self) -> Result<f64, ShellError>
pub fn as_filesize(&self) -> Result<i64, ShellError>
pub fn as_duration(&self) -> Result<i64, ShellError>
pub fn as_date(&self) -> Result<DateTime<FixedOffset>, ShellError>
pub fn as_range(&self) -> Result<&Range, ShellError>
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_char(&self) -> Result<char, ShellError>
pub fn as_path(&self) -> Result<PathBuf, ShellError>
pub fn as_record(&self) -> Result<&Record, ShellError>
pub fn as_list(&self) -> Result<&[Value], ShellError>
pub fn as_block(&self) -> Result<BlockId, ShellError>
pub fn as_closure( &self ) -> Result<(BlockId, &HashMap<VarId, Value>), ShellError>
pub fn as_binary(&self) -> Result<&[u8], ShellError>
pub fn as_cell_path(&self) -> Result<&CellPath, ShellError>
pub fn as_custom_value(&self) -> Result<&dyn CustomValue, ShellError>
pub fn as_lazy_record(&self) -> Result<&dyn for<'a> LazyRecord<'a>, ShellError>
pub fn as_match_pattern(&self) -> Result<&MatchPattern, ShellError>
pub fn get_data_by_key(&self, name: &str) -> Option<Value>
pub fn nonerror_into_string( &self, separator: &str, config: &Config ) -> Result<String, ShellError>
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 into_string_parsable(&self, separator: &str, config: &Config) -> String
pub fn into_string_parsable(&self, separator: &str, config: &Config) -> String
Convert Value into a parsable string (quote strings) bugbug other, rarer types not handled
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
pub fn is_error(&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 cell 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 cell 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<'a>(
&mut self,
cell_path: &[PathMember],
callback: Box<dyn FnOnce(&Value) -> Value + 'a>
) -> Result<(), ShellError>
pub fn update_cell_path<'a>( &mut self, cell_path: &[PathMember], callback: Box<dyn FnOnce(&Value) -> Value + 'a> ) -> Result<(), ShellError>
Follow a given cell 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, head_span: Span ) -> Result<(), ShellError>
pub fn is_true(&self) -> bool
pub fn is_false(&self) -> bool
pub fn columns(&self) -> &[String]
pub fn bool(val: bool, span: Span) -> Value
pub fn int(val: i64, span: Span) -> Value
pub fn float(val: f64, span: Span) -> Value
pub fn filesize(val: i64, span: Span) -> Value
pub fn duration(val: i64, span: Span) -> Value
pub fn date(val: DateTime<FixedOffset>, span: Span) -> Value
pub fn range(val: Range, span: Span) -> Value
pub fn string(val: impl Into<String>, span: Span) -> Value
pub fn record(val: Record, span: Span) -> Value
pub fn list(vals: Vec<Value>, span: Span) -> Value
pub fn block(val: BlockId, span: Span) -> Value
pub fn closure( val: BlockId, captures: HashMap<VarId, Value>, span: Span ) -> Value
pub fn error(error: ShellError, span: Span) -> Value
pub fn binary(val: impl Into<Vec<u8>>, span: Span) -> Value
pub fn cell_path(val: CellPath, span: Span) -> Value
pub fn custom_value(val: Box<dyn CustomValue>, span: Span) -> Value
pub fn lazy_record(val: Box<dyn for<'a> LazyRecord<'a>>, span: Span) -> Value
pub fn match_pattern(val: MatchPattern, span: Span) -> Value
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_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_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_duration(val: i64) -> Value
pub fn test_duration(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_date(val: DateTime<FixedOffset>) -> Value
pub fn test_date(val: DateTime<FixedOffset>) -> 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_range(val: Range) -> Value
pub fn test_range(val: Range) -> 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_string(val: impl Into<String>) -> Value
pub fn test_string(val: 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_record(val: Record) -> Value
pub fn test_record(val: Record) -> 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_list(vals: Vec<Value>) -> Value
pub fn test_list(vals: Vec<Value>) -> 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_block(val: BlockId) -> Value
pub fn test_block(val: BlockId) -> 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_closure(val: BlockId, captures: HashMap<VarId, Value>) -> Value
pub fn test_closure(val: BlockId, captures: HashMap<VarId, Value>) -> 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.
sourcepub fn test_binary(val: impl Into<Vec<u8>>) -> Value
pub fn test_binary(val: impl Into<Vec<u8>>) -> 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_cell_path(val: CellPath) -> Value
pub fn test_cell_path(val: CellPath) -> 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_custom_value(val: Box<dyn CustomValue>) -> Value
pub fn test_custom_value(val: Box<dyn CustomValue>) -> 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_lazy_record(val: Box<dyn for<'a> LazyRecord<'a>>) -> Value
pub fn test_lazy_record(val: Box<dyn for<'a> LazyRecord<'a>>) -> 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_match_pattern(val: MatchPattern) -> Value
pub fn test_match_pattern(val: MatchPattern) -> Value
Note: Only use this for test data, not live data, as it will point into unknown source when used in errors.
source§impl 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, engine_state: &EngineState, 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 xor( &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§
source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
source§fn 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>,
source§impl FromValue for Value
impl FromValue for Value
fn from_value(v: &Value) -> Result<Self, ShellError>
source§impl PartialEq<Value> for Value
impl PartialEq<Value> for Value
source§impl PartialOrd<Value> for Value
impl PartialOrd<Value> for Value
1.0.0 · source§fn 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§
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
source§impl<V> IntoPipelineData for Vwhere
V: Into<Value>,
impl<V> IntoPipelineData for Vwhere V: Into<Value>,
fn into_pipeline_data(self) -> PipelineData
fn into_pipeline_data_with_metadata( self, metadata: impl Into<Option<Box<PipelineMetadata, Global>>> ) -> PipelineData
§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 on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, 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 on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, 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 blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'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 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,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more