pub enum NixValue {
Int(i64),
Float(f64),
Bool(bool),
Str(String),
Null,
Ident(String),
List(Vec<NixValue>),
AttrSet(BTreeMap<String, NixValue>),
}Expand description
A minimal Nix value representation — enough to round-trip any SExpr value through a Nix expression literal.
Variants§
Int(i64)
Float(f64)
Bool(bool)
Str(String)
Null
Ident(String)
Bare identifier. In Nix expressions this is a variable reference; we use it to encode sexpr symbols.
List(Vec<NixValue>)
AttrSet(BTreeMap<String, NixValue>)
Attribute set. BTreeMap for deterministic iteration order.
Implementations§
Source§impl NixValue
impl NixValue
Sourcepub fn from_sexpr(s: &SExpr) -> Self
pub fn from_sexpr(s: &SExpr) -> Self
Sourcepub fn to_sexpr(&self) -> SExpr
pub fn to_sexpr(&self) -> SExpr
Convert back to an SExpr. The round-trip is lossless for
values originally produced by Self::from_sexpr.
Disambiguation rules:
- AttrSet with a
headkey → struct-form(head (:k v) ...) - AttrSet without a
headkey → still struct-form with synthetic headattrs - List →
(list ...)if it looks like aVec<T>(first item is the symbollist), else a tuple-tag list with the first element as the head.
Trait Implementations§
impl StructuralPartialEq for NixValue
Auto Trait Implementations§
impl Freeze for NixValue
impl RefUnwindSafe for NixValue
impl Send for NixValue
impl Sync for NixValue
impl Unpin for NixValue
impl UnsafeUnpin for NixValue
impl UnwindSafe for NixValue
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
Mutably borrows from an owned value. Read more