pub enum Primitive {
}
Expand description
The most fundamental of structured values in Nu are the Primitive values. These values represent types like integers, strings, booleans, dates, etc that are then used as the building blocks of more complex structures.
Primitives also include marker values BeginningOfStream and EndOfStream which denote a change of condition in the stream
Variants
Nothing
An empty value
Int(i64)
A common integer
BigInt(BigInt)
A “big int”, an integer with arbitrarily large size (aka not limited to 64-bit)
Decimal(BigDecimal)
A “big decimal”, an decimal number with arbitrarily large size (aka not limited to 64-bit)
Filesize(u64)
A count in the number of bytes, used as a filesize
String(String)
A string value
ColumnPath(ColumnPath)
A path to travel to reach a value in a table
GlobPattern(String)
A glob pattern, eg foo*
Boolean(bool)
A boolean value
Date(DateTime<FixedOffset>)
A date value
Duration(BigInt)
A count in the number of nanoseconds
Range(Box<Range>)
A range of values
FilePath(PathBuf)
A file path
Binary(Vec<u8>)
A vector of raw binary data
BeginningOfStream
Beginning of stream marker, a pseudo-value not intended for tables
EndOfStream
End of stream marker, a pseudo-value not intended for tables
Implementations
sourceimpl Primitive
impl Primitive
sourcepub fn as_char(&self, span: Span) -> Result<char, ShellError>
pub fn as_char(&self, span: Span) -> Result<char, ShellError>
Converts a primitive value to a char, if possible. Uses a span to build an error if the conversion isn’t possible.
sourcepub fn as_usize(&self, span: Span) -> Result<usize, ShellError>
pub fn as_usize(&self, span: Span) -> Result<usize, ShellError>
Converts a primitive value to a u64, if possible. Uses a span to build an error if the conversion isn’t possible.
sourcepub fn as_u64(&self, span: Span) -> Result<u64, ShellError>
pub fn as_u64(&self, span: Span) -> Result<u64, ShellError>
Converts a primitive value to a u64, if possible. Uses a span to build an error if the conversion isn’t possible.
sourcepub fn as_f64(&self, span: Span) -> Result<f64, ShellError>
pub fn as_f64(&self, span: Span) -> Result<f64, ShellError>
Converts a primitive value to a f64, if possible. Uses a span to build an error if the conversion isn’t possible.
sourcepub fn as_i64(&self, span: Span) -> Result<i64, ShellError>
pub fn as_i64(&self, span: Span) -> Result<i64, ShellError>
Converts a primitive value to a i64, if possible. Uses a span to build an error if the conversion isn’t possible.
sourcepub fn as_u32(&self, span: Span) -> Result<u32, ShellError>
pub fn as_u32(&self, span: Span) -> Result<u32, ShellError>
Converts a primitive value to a u32, if possible. Uses a span to build an error if the conversion isn’t possible.
pub fn as_i32(&self, span: Span) -> Result<i32, ShellError>
pub fn as_i16(&self, span: Span) -> Result<i16, ShellError>
pub fn as_f32(&self, span: Span) -> Result<f32, ShellError>
pub fn into_chrono_duration(self, span: Span) -> Result<Duration, ShellError>
pub fn into_string(self, span: Span) -> Result<String, ShellError>
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Primitive
impl<'de> Deserialize<'de> for Primitive
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<BigDecimal> for Primitive
impl From<BigDecimal> for Primitive
sourcefn from(decimal: BigDecimal) -> Primitive
fn from(decimal: BigDecimal) -> Primitive
Helper to convert from decimals to a Primitive value
sourceimpl Ord for Primitive
impl Ord for Primitive
sourceimpl PartialOrd<Primitive> for Primitive
impl PartialOrd<Primitive> for Primitive
sourcefn partial_cmp(&self, other: &Primitive) -> Option<Ordering>
fn partial_cmp(&self, other: &Primitive) -> 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 Primitive
impl PrettyDebug for Primitive
sourcefn pretty(&self) -> DebugDocBuilder
fn pretty(&self) -> DebugDocBuilder
Get a Primitive 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 PrettyType for Primitive
impl PrettyType for Primitive
sourcefn pretty_type(&self) -> DebugDocBuilder
fn pretty_type(&self) -> DebugDocBuilder
Find the type of the Value and prepare it for pretty-printing
sourceimpl ShellTypeName for Primitive
impl ShellTypeName for Primitive
impl Eq for Primitive
impl StructuralEq for Primitive
impl StructuralPartialEq for Primitive
Auto Trait Implementations
impl RefUnwindSafe for Primitive
impl Send for Primitive
impl Sync for Primitive
impl Unpin for Primitive
impl UnwindSafe for Primitive
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> 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