Enum nu_protocol::Value

source ·
pub enum Value {
Show 19 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, span: Span, }, Closure { val: BlockId, captures: HashMap<VarId, Value>, span: Span, }, Nothing { span: Span, }, Error { error: Box<ShellError>, }, Binary { val: Vec<u8>, span: Span, }, CellPath { val: CellPath, span: Span, }, CustomValue { val: Box<dyn CustomValue>, span: Span, }, LazyRecord { val: Box<dyn LazyRecord>, span: Span, }, MatchPattern { val: Box<MatchPattern>, span: Span, },
}
Expand description

Core structured values that pass through the pipeline in Nushell.

Variants§

§

Bool

Fields

§val: bool
§span: Span
§

Int

Fields

§val: i64
§span: Span
§

Float

Fields

§val: f64
§span: Span
§

Filesize

Fields

§val: i64
§span: Span
§

Duration

Fields

§val: i64
§span: Span
§

Date

Fields

§span: Span
§

Range

Fields

§val: Box<Range>
§span: Span
§

String

Fields

§span: Span
§

Record

Fields

§cols: Vec<String>
§vals: Vec<Value>
§span: Span
§

List

Fields

§vals: Vec<Value>
§span: Span
§

Block

Fields

§span: Span
§

Closure

Fields

§captures: HashMap<VarId, Value>
§span: Span
§

Nothing

Fields

§span: Span
§

Error

Fields

§

Binary

Fields

§val: Vec<u8>
§span: Span
§

CellPath

Fields

§span: Span
§

CustomValue

Fields

§val: Box<dyn CustomValue>
§span: Span
§

LazyRecord

Fields

§val: Box<dyn LazyRecord>
§span: Span
§

MatchPattern

Fields

§span: Span

Implementations§

source§

impl Value

source

pub fn into_config(&mut self, config: &Config) -> (Config, Option<ShellError>)

source§

impl Value

source

pub fn as_f64(&self) -> Result<f64, ShellError>

source

pub fn as_i64(&self) -> Result<i64, ShellError>

source§

impl Value

source

pub fn as_char(&self) -> Result<char, ShellError>

source

pub fn as_string(&self) -> Result<String, ShellError>

Converts into string values that can be changed into string natively

source

pub fn as_spanned_string(&self) -> Result<Spanned<String>, ShellError>

source

pub fn as_path(&self) -> Result<PathBuf, ShellError>

source

pub fn as_block(&self) -> Result<BlockId, ShellError>

source

pub fn as_binary(&self) -> Result<&[u8], ShellError>

source

pub fn as_record(&self) -> Result<(&[String], &[Value]), ShellError>

source

pub fn as_list(&self) -> Result<&[Value], ShellError>

source

pub fn as_bool(&self) -> Result<bool, ShellError>

source

pub fn as_float(&self) -> Result<f64, ShellError>

source

pub fn as_integer(&self) -> Result<i64, ShellError>

source

pub fn span(&self) -> Result<Span, ShellError>

Get the span for the current value

source

pub fn expect_span(&self) -> Span

Special variant of the above designed to be called only in situations where the value not being a Value::Error has been guaranteed by match arms.

source

pub fn with_span(self, new_span: Span) -> Value

Update the value with a new span

source

pub fn get_type(&self) -> Type

Get the type of the current Value

source

pub fn get_data_by_key(&self, name: &str) -> Option<Value>

source

pub fn nonerror_into_string( &self, separator: &str, config: &Config ) -> Result<String, ShellError>

source

pub fn into_string(&self, separator: &str, config: &Config) -> String

Convert Value into string. Note that Streams will be consumed.

source

pub fn into_abbreviated_string(&self, config: &Config) -> String

Convert Value into string. Note that Streams will be consumed.

source

pub fn debug_value(&self) -> String

Convert Value into a debug string

source

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

source

pub fn debug_string(&self, separator: &str, config: &Config) -> String

Convert Value into string. Note that Streams will be consumed.

source

pub fn is_empty(&self) -> bool

Check if the content is empty

source

pub fn is_nothing(&self) -> bool

source

pub fn nothing(span: Span) -> Value

Create a new Nothing value

source

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

source

pub fn follow_cell_path_not_from_user_input( self, cell_path: &[PathMember], insensitive: bool ) -> Result<Value, ShellError>

source

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

source

pub fn upsert_data_at_cell_path( &mut self, cell_path: &[PathMember], new_val: Value ) -> Result<(), ShellError>

source

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

source

pub fn update_data_at_cell_path( &mut self, cell_path: &[PathMember], new_val: Value ) -> Result<(), ShellError>

source

pub fn remove_data_at_cell_path( &mut self, cell_path: &[PathMember] ) -> Result<(), ShellError>

source

pub fn insert_data_at_cell_path( &mut self, cell_path: &[PathMember], new_val: Value, head_span: Span ) -> Result<(), ShellError>

source

pub fn is_true(&self) -> bool

source

pub fn is_false(&self) -> bool

source

pub fn columns(&self) -> Vec<String>

source

pub fn string(val: impl Into<String>, span: Span) -> Value

source

pub fn binary(val: impl Into<Vec<u8>>, span: Span) -> Value

source

pub fn int(val: i64, span: Span) -> Value

source

pub fn float(val: f64, span: Span) -> Value

source

pub fn boolean(val: bool, span: Span) -> Value

source

pub fn record(cols: Vec<String>, vals: Vec<Value>, span: Span) -> Value

source

pub fn record_from_hashmap(map: &HashMap<String, Value>, span: Span) -> Value

source

pub fn list(vals: Vec<Value>, span: Span) -> Value

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn test_record(cols: Vec<impl Into<String>>, 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.

source

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.

source§

impl Value

source

pub fn add( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn append( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn sub( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn mul( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn div( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn floor_div( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn lt(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError>

source

pub fn lte( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn gt(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError>

source

pub fn gte( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn eq(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError>

source

pub fn ne(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError>

source

pub fn in(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError>

source

pub fn not_in( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn regex_match( &self, engine_state: &EngineState, op: Span, rhs: &Value, invert: bool, span: Span ) -> Result<Value, ShellError>

source

pub fn starts_with( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn ends_with( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn bit_shl( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn bit_shr( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn bit_or( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn bit_xor( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn bit_and( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn modulo( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn and( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn or(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError>

source

pub fn xor( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

source

pub fn pow( &self, op: Span, rhs: &Value, span: Span ) -> Result<Value, ShellError>

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Value

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Value

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Value

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<Spanned<HashMap<String, Value, RandomState>>> for Value

Create a Value::Record from a spanned hashmap

source§

fn from(input: Spanned<HashMap<String, Value>>) -> Self

Converts to this type from the input type.
source§

impl From<Spanned<IndexMap<String, Value, RandomState>>> for Value

Create a Value::Record from a spanned indexmap

source§

fn from(input: Spanned<IndexMap<String, Value>>) -> Self

Converts to this type from the input type.
source§

impl FromValue for Value

source§

impl PartialEq<Value> for Value

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Value> for Value

source§

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 · source§

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 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Value

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. 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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<V> IntoPipelineData for Vwhere V: Into<Value>,

§

impl<D> OwoColorize for D

§

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,

Set the background color generically. Read more
§

fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>

Change the foreground color to black
§

fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>

Change the background color to black
§

fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>

Change the foreground color to red
§

fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>

Change the background color to red
§

fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>

Change the foreground color to green
§

fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>

Change the background color to green
§

fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>

Change the foreground color to yellow
§

fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>

Change the background color to yellow
§

fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>

Change the foreground color to blue
§

fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>

Change the background color to blue
§

fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to magenta
§

fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to magenta
§

fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to purple
§

fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to purple
§

fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>

Change the foreground color to cyan
§

fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>

Change the background color to cyan
§

fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>

Change the foreground color to white
§

fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>

Change the background color to white
§

fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>

Change the foreground color to the terminal default
§

fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>

Change the background color to the terminal default
§

fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>

Change the foreground color to bright black
§

fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>

Change the background color to bright black
§

fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>

Change the foreground color to bright red
§

fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>

Change the background color to bright red
§

fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>

Change the foreground color to bright green
§

fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>

Change the background color to bright green
§

fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>

Change the foreground color to bright yellow
§

fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>

Change the background color to bright yellow
§

fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>

Change the foreground color to bright blue
§

fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>

Change the background color to bright blue
§

fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright magenta
§

fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright magenta
§

fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright purple
§

fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright purple
§

fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>

Change the foreground color to bright cyan
§

fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>

Change the background color to bright cyan
§

fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>

Change the foreground color to bright white
§

fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>

Change the background color to bright white
§

fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>

Make the text bold
§

fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>

Make the text dim
§

fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>

Make the text italicized
§

fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>

Make the text italicized
Make the text blink
Make the text blink (but fast!)
§

fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>

Swap the foreground and background colors
§

fn hidden<'a>(&'a self) -> HiddenDisplay<'a, Self>

Hide the text
§

fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>

Cross out the text
§

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,

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>

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>

Set the background color to a specific RGB value.
§

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>

Sets the background color to an RGB value.
§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
source§

impl<T> Serialize for Twhere T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,