pub struct Value(/* private fields */);Expand description
The core Value type for all Sema data. NaN-boxed: stored as 8 bytes. Floats stored directly, everything else encoded in quiet-NaN payload space.
Implementations§
Source§impl Value
impl Value
pub const NIL: Value
pub const TRUE: Value
pub const FALSE: Value
pub fn nil() -> Value
pub fn bool(b: bool) -> Value
pub fn int(n: i64) -> Value
pub fn float(f: f64) -> Value
pub fn char(c: char) -> Value
pub fn symbol_from_spur(spur: Spur) -> Value
pub fn symbol(s: &str) -> Value
pub fn keyword_from_spur(spur: Spur) -> Value
pub fn keyword(s: &str) -> Value
pub fn string(s: &str) -> Value
pub fn string_from_rc(rc: Rc<String>) -> Value
pub fn list(v: Vec<Value>) -> Value
pub fn list_from_rc(rc: Rc<Vec<Value>>) -> Value
pub fn vector(v: Vec<Value>) -> Value
pub fn vector_from_rc(rc: Rc<Vec<Value>>) -> Value
pub fn map(m: BTreeMap<Value, Value>) -> Value
pub fn map_from_rc(rc: Rc<BTreeMap<Value, Value>>) -> Value
pub fn hashmap(entries: Vec<(Value, Value)>) -> Value
pub fn hashmap_from_rc(rc: Rc<HashMap<Value, Value>>) -> Value
pub fn lambda(l: Lambda) -> Value
pub fn lambda_from_rc(rc: Rc<Lambda>) -> Value
pub fn macro_val(m: Macro) -> Value
pub fn macro_from_rc(rc: Rc<Macro>) -> Value
pub fn native_fn(f: NativeFn) -> Value
pub fn native_fn_from_rc(rc: Rc<NativeFn>) -> Value
pub fn prompt(p: Prompt) -> Value
pub fn prompt_from_rc(rc: Rc<Prompt>) -> Value
pub fn message(m: Message) -> Value
pub fn message_from_rc(rc: Rc<Message>) -> Value
pub fn conversation(c: Conversation) -> Value
pub fn conversation_from_rc(rc: Rc<Conversation>) -> Value
pub fn tool_def(t: ToolDefinition) -> Value
pub fn tool_def_from_rc(rc: Rc<ToolDefinition>) -> Value
pub fn agent(a: Agent) -> Value
pub fn agent_from_rc(rc: Rc<Agent>) -> Value
pub fn thunk(t: Thunk) -> Value
pub fn thunk_from_rc(rc: Rc<Thunk>) -> Value
pub fn record(r: Record) -> Value
pub fn record_from_rc(rc: Rc<Record>) -> Value
pub fn bytevector(bytes: Vec<u8>) -> Value
pub fn bytevector_from_rc(rc: Rc<Vec<u8>>) -> Value
Source§impl Value
impl Value
Sourcepub unsafe fn from_raw_bits(bits: u64) -> Value
pub unsafe fn from_raw_bits(bits: u64) -> Value
Construct a Value from raw NaN-boxed bits.
§Safety
Caller must ensure bits represents a valid NaN-boxed value.
For immediate types (nil, bool, int, symbol, keyword, char), this is always safe.
For heap-pointer types, the encoded pointer must be valid and have its Rc ownership
accounted for (i.e., the caller must ensure the refcount is correct).
Sourcepub fn raw_tag(&self) -> Option<u64>
pub fn raw_tag(&self) -> Option<u64>
Get the NaN-boxing tag of a boxed value (0-63).
Returns None for non-boxed values (floats).
Sourcepub fn as_native_fn_ref(&self) -> Option<&NativeFn>
pub fn as_native_fn_ref(&self) -> Option<&NativeFn>
Borrow the underlying NativeFn without bumping the Rc refcount. SAFETY: The returned reference is valid as long as this Value is alive.
Sourcepub fn view(&self) -> ValueView
pub fn view(&self) -> ValueView
Pattern-match friendly view of this value. For heap types, this bumps the Rc refcount.
pub fn type_name(&self) -> &'static str
pub fn is_nil(&self) -> bool
pub fn is_truthy(&self) -> bool
pub fn is_bool(&self) -> bool
pub fn is_int(&self) -> bool
pub fn is_symbol(&self) -> bool
pub fn is_keyword(&self) -> bool
pub fn is_string(&self) -> bool
pub fn is_list(&self) -> bool
pub fn is_pair(&self) -> bool
pub fn is_vector(&self) -> bool
pub fn is_map(&self) -> bool
pub fn is_lambda(&self) -> bool
pub fn is_native_fn(&self) -> bool
pub fn is_thunk(&self) -> bool
pub fn is_record(&self) -> bool
pub fn as_int(&self) -> Option<i64>
pub fn as_float(&self) -> Option<f64>
pub fn as_bool(&self) -> Option<bool>
pub fn as_str(&self) -> Option<&str>
pub fn as_string_rc(&self) -> Option<Rc<String>>
pub fn as_symbol(&self) -> Option<String>
pub fn as_symbol_spur(&self) -> Option<Spur>
pub fn as_keyword(&self) -> Option<String>
pub fn as_keyword_spur(&self) -> Option<Spur>
pub fn as_char(&self) -> Option<char>
pub fn as_list(&self) -> Option<&[Value]>
pub fn as_list_rc(&self) -> Option<Rc<Vec<Value>>>
pub fn as_vector(&self) -> Option<&[Value]>
pub fn as_vector_rc(&self) -> Option<Rc<Vec<Value>>>
pub fn as_map_rc(&self) -> Option<Rc<BTreeMap<Value, Value>>>
pub fn as_hashmap_rc(&self) -> Option<Rc<HashMap<Value, Value>>>
pub fn as_lambda_rc(&self) -> Option<Rc<Lambda>>
pub fn as_macro_rc(&self) -> Option<Rc<Macro>>
pub fn as_native_fn_rc(&self) -> Option<Rc<NativeFn>>
pub fn as_thunk_rc(&self) -> Option<Rc<Thunk>>
pub fn as_record(&self) -> Option<&Record>
pub fn as_record_rc(&self) -> Option<Rc<Record>>
pub fn as_bytevector(&self) -> Option<&[u8]>
pub fn as_bytevector_rc(&self) -> Option<Rc<Vec<u8>>>
pub fn as_prompt_rc(&self) -> Option<Rc<Prompt>>
pub fn as_message_rc(&self) -> Option<Rc<Message>>
pub fn as_conversation_rc(&self) -> Option<Rc<Conversation>>
pub fn as_tool_def_rc(&self) -> Option<Rc<ToolDefinition>>
pub fn as_agent_rc(&self) -> Option<Rc<Agent>>
Trait Implementations§
Source§impl Ord for Value
impl Ord for Value
Source§impl PartialOrd for Value
impl PartialOrd for Value
impl Eq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl UnwindSafe for Value
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.