Struct nu_protocol::value::Value
source · [−]pub struct Value {
pub value: UntaggedValue,
pub tag: Tag,
}
Expand description
The fundamental structured value that flows through the pipeline, with associated metadata
Fields
value: UntaggedValue
tag: Tag
Implementations
sourceimpl Value
impl Value
sourcepub fn new(untagged_value: UntaggedValue, the_tag: Tag) -> Self
pub fn new(untagged_value: UntaggedValue, the_tag: Tag) -> Self
Helper to create a Value
sourcepub fn anchor(&self) -> Option<AnchorLocation>
pub fn anchor(&self) -> Option<AnchorLocation>
Get the corresponding anchor (originating location) for the Value
sourcepub fn anchor_name(&self) -> Option<String>
pub fn anchor_name(&self) -> Option<String>
Get the name (url, filepath, etc) behind an anchor for the Value
pub fn error(e: ShellError) -> Value
sourcepub fn as_string(&self) -> Result<String, ShellError>
pub fn as_string(&self) -> Result<String, ShellError>
View the Value as a string, if possible
sourcepub fn as_filepath(&self) -> Result<PathBuf, ShellError>
pub fn as_filepath(&self) -> Result<PathBuf, ShellError>
View the Value as a FilePath (PathBuf), if possible
sourcepub fn as_int(&self) -> Result<i64, ShellError>
pub fn as_int(&self) -> Result<i64, ShellError>
View the Value as a Int, if possible
sourcepub fn as_big_int(&self) -> Result<BigInt, ShellError>
pub fn as_big_int(&self) -> Result<BigInt, ShellError>
View the Value as a Int, if possible
sourcepub fn as_filesize(&self) -> Result<u64, ShellError>
pub fn as_filesize(&self) -> Result<u64, ShellError>
View the Value as a Filesize (u64), if possible
sourcepub fn as_duration(&self) -> Result<BigInt, ShellError>
pub fn as_duration(&self) -> Result<BigInt, ShellError>
View the Value as a Duration (BigInt), if possible
sourcepub fn as_decimal(&self) -> Result<BigDecimal, ShellError>
pub fn as_decimal(&self) -> Result<BigDecimal, ShellError>
View the Value as a Decimal (BigDecimal), if possible
pub fn convert_to_string(&self) -> String
pub fn format(&self, fmt: &str) -> Result<String, ShellError>
sourcepub fn as_binary_vec(&self) -> Result<Vec<u8>, ShellError>
pub fn as_binary_vec(&self) -> Result<Vec<u8>, ShellError>
View a Primitive::Binary as a Vec
sourcepub fn as_forgiving_string(&self) -> Result<&str, ShellError>
pub fn as_forgiving_string(&self) -> Result<&str, ShellError>
View into the borrowed string contents of a Value, if possible
sourcepub fn as_path(&self) -> Result<PathBuf, ShellError>
pub fn as_path(&self) -> Result<PathBuf, ShellError>
View the Value as a path, if possible
sourcepub fn as_primitive(&self) -> Result<Primitive, ShellError>
pub fn as_primitive(&self) -> Result<Primitive, ShellError>
View the Value as a Primitive value, if possible
sourcepub fn is_primitive(&self) -> bool
pub fn is_primitive(&self) -> bool
View the Value as a Primitive value, if possible
sourcepub fn as_char(&self) -> Result<char, ShellError>
pub fn as_char(&self) -> Result<char, ShellError>
View the Value as char, if possible
sourcepub fn as_usize(&self) -> Result<usize, ShellError>
pub fn as_usize(&self) -> Result<usize, ShellError>
View the Value as unsigned size, if possible
sourcepub fn as_u64(&self) -> Result<u64, ShellError>
pub fn as_u64(&self) -> Result<u64, ShellError>
View the Value as unsigned 64-bit, if possible
sourcepub fn as_i64(&self) -> Result<i64, ShellError>
pub fn as_i64(&self) -> Result<i64, ShellError>
View the Value as signed 64-bit, if possible
sourcepub fn as_u32(&self) -> Result<u32, ShellError>
pub fn as_u32(&self) -> Result<u32, ShellError>
View the Value as unsigned 32-bit, if possible
sourcepub fn as_i32(&self) -> Result<i32, ShellError>
pub fn as_i32(&self) -> Result<i32, ShellError>
View the Value as signed 32-bit, if possible
sourcepub fn as_i16(&self) -> Result<i16, ShellError>
pub fn as_i16(&self) -> Result<i16, ShellError>
View the Value as signed 16-bit, if possible
sourcepub fn as_f32(&self) -> Result<f32, ShellError>
pub fn as_f32(&self) -> Result<f32, ShellError>
View the Value as signed 32-bit float, if possible
sourcepub fn as_f64(&self) -> Result<f64, ShellError>
pub fn as_f64(&self) -> Result<f64, ShellError>
View the Value as signed 64-bit float, if possible
sourcepub fn as_bool(&self) -> Result<bool, ShellError>
pub fn as_bool(&self) -> Result<bool, ShellError>
View the Value as boolean, if possible
sourcepub fn table_entries(&self) -> TableValueIter<'_>ⓘNotable traits for TableValueIter<'a>impl<'a> Iterator for TableValueIter<'a> type Item = &'a Value;
pub fn table_entries(&self) -> TableValueIter<'_>ⓘNotable traits for TableValueIter<'a>impl<'a> Iterator for TableValueIter<'a> type Item = &'a Value;
Returns an iterator of the values rows
sourcepub fn row_entries(&self) -> RowValueIter<'_>ⓘNotable traits for RowValueIter<'a>impl<'a> Iterator for RowValueIter<'a> type Item = (&'a String, &'a Value);
pub fn row_entries(&self) -> RowValueIter<'_>ⓘNotable traits for RowValueIter<'a>impl<'a> Iterator for RowValueIter<'a> type Item = (&'a String, &'a Value);
Returns an iterator of the value’s cells
pub fn nothing() -> Value
Methods from Deref<Target = UntaggedValue>
sourcepub fn data_descriptors(&self) -> Vec<String>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn data_descriptors(&self) -> Vec<String>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get the corresponding descriptors (column names) associated with this value
sourcepub fn is_filesize(&self) -> bool
pub fn is_filesize(&self) -> bool
Returns true if this value represents a filesize
sourcepub fn is_duration(&self) -> bool
pub fn is_duration(&self) -> bool
Returns true if this value represents a duration
sourcepub fn is_some(&self) -> bool
pub fn is_some(&self) -> bool
Returns true if the value represents something other than Nothing
sourcepub fn expect_error(&self) -> ShellError
pub fn expect_error(&self) -> ShellError
Expect this value to be an error and return it
sourcepub fn expect_string(&self) -> &str
pub fn expect_string(&self) -> &str
Expect this value to be a string and return it
sourcepub fn expect_int(&self) -> i64
pub fn expect_int(&self) -> i64
Expect this value to be an integer and return it
Trait Implementations
sourceimpl Deref for Value
impl Deref for Value
Overload deferencing to give back the UntaggedValue inside of a Value
type Target = UntaggedValue
type Target = UntaggedValue
The resulting type after dereferencing.
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<'a> From<&'a Value> for &'a UntaggedValue
impl<'a> From<&'a Value> for &'a UntaggedValue
Convert a borrowed Value into a borrowed UntaggedValue
sourceimpl From<TaggedDictBuilder> for Value
impl From<TaggedDictBuilder> for Value
sourcefn from(input: TaggedDictBuilder) -> Value
fn from(input: TaggedDictBuilder) -> Value
Convert a builder into a tagged Value
sourceimpl From<UntaggedValue> for Value
impl From<UntaggedValue> for Value
sourcefn from(value: UntaggedValue) -> Value
fn from(value: UntaggedValue) -> Value
Convert an UntaggedValue into a Value with a default tag
sourceimpl From<Value> for UntaggedValue
impl From<Value> for UntaggedValue
sourcefn from(v: Value) -> UntaggedValue
fn from(v: Value) -> UntaggedValue
Convert a Value into an UntaggedValue
sourceimpl Ord for Value
impl Ord for Value
sourceimpl PartialEq<Value> for Dictionary
impl PartialEq<Value> for Dictionary
sourceimpl PartialOrd<Value> for Value
impl PartialOrd<Value> for Value
sourcefn partial_cmp(&self, other: &Value) -> Option<Ordering>
fn partial_cmp(&self, other: &Value) -> 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
sourceimpl PrettyDebug for &Value
impl PrettyDebug for &Value
sourcefn pretty(&self) -> DebugDocBuilder
fn pretty(&self) -> DebugDocBuilder
Get a borrowed Value ready to be pretty-printed
fn to_doc(&self) -> DebugDoc
fn pretty_doc(
&self
) -> Doc<'static, BoxDoc<'static, ShellAnnotation>, ShellAnnotation>
fn pretty_builder(&self) -> DocBuilder<'static, BoxAllocator, ShellAnnotation>
sourcefn display(&self) -> String
fn display(&self) -> String
A convenience method that prints out the document without colors in 70 columns. Generally, you should use plain_string or colored_string if possible, but display() can be useful for trace lines and things like that, where you don’t have control over the terminal. Read more
fn plain_string(&self, width: usize) -> String
fn colored_string(&self, width: usize) -> String
sourceimpl PrettyDebug for Value
impl PrettyDebug for Value
sourcefn pretty(&self) -> DebugDocBuilder
fn pretty(&self) -> DebugDocBuilder
Get a Value ready to be pretty-printed
fn to_doc(&self) -> DebugDoc
fn pretty_doc(
&self
) -> Doc<'static, BoxDoc<'static, ShellAnnotation>, ShellAnnotation>
fn pretty_builder(&self) -> DocBuilder<'static, BoxAllocator, ShellAnnotation>
sourcefn display(&self) -> String
fn display(&self) -> String
A convenience method that prints out the document without colors in 70 columns. Generally, you should use plain_string or colored_string if possible, but display() can be useful for trace lines and things like that, where you don’t have control over the terminal. Read more
fn plain_string(&self, width: usize) -> String
fn colored_string(&self, width: usize) -> String
sourceimpl ShellTypeName for Value
impl ShellTypeName for Value
sourceimpl TryFrom<&'_ Value> for i64
impl TryFrom<&'_ Value> for i64
type Error = ShellError
type Error = ShellError
The type returned in the event of a conversion error.
sourceimpl TryFrom<&'_ Value> for String
impl TryFrom<&'_ Value> for String
type Error = ShellError
type Error = ShellError
The type returned in the event of a conversion error.
sourceimpl TryFrom<&'_ Value> for Vec<u8>
impl TryFrom<&'_ Value> for Vec<u8>
type Error = ShellError
type Error = ShellError
The type returned in the event of a conversion error.
sourceimpl<'a> TryFrom<&'a Value> for &'a Dictionary
impl<'a> TryFrom<&'a Value> for &'a Dictionary
sourcefn try_from(value: &'a Value) -> Result<&'a Dictionary, ShellError>
fn try_from(value: &'a Value) -> Result<&'a Dictionary, ShellError>
Convert to a dictionary, if possible
type Error = ShellError
type Error = ShellError
The type returned in the event of a conversion error.
impl Eq for Value
impl StructuralEq for Value
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 · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> HasFallibleSpan for T where
T: HasSpan,
impl<T> HasFallibleSpan for T where
T: HasSpan,
pub fn maybe_span(&self) -> Option<Span>
sourceimpl<T> IntoSpanned for T where
T: HasFallibleSpan,
impl<T> IntoSpanned for T where
T: HasFallibleSpan,
type Output = T
pub fn into_spanned(self, _span: impl Into<Span>) -> <T as IntoSpanned>::Output
sourceimpl<T> PrettyDebugWithSource for T where
T: PrettyDebug,
impl<T> PrettyDebugWithSource for T where
T: PrettyDebug,
pub fn pretty_debug(&self, _source: &str) -> DebugDocBuilder
fn refined_pretty_debug(
&self,
_refine: PrettyDebugRefineKind,
source: &str
) -> DebugDocBuilder
fn debug(&self, source: impl Into<Text>) -> String where
Self: Clone,
fn debuggable(self, source: impl Into<Text>) -> DebuggableWithSource<Self>
sourceimpl<T> SpannedItem for T
impl<T> SpannedItem for T
sourceimpl<T> TaggedItem for T
impl<T> TaggedItem for T
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.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more