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: SpanError
Fields
error: ShellErrorBinary
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 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
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