MCPcopy Create free account
hub / github.com/argumentcomputer/ix / get

Method get

crates/ixon/src/lazy.rs:150–164  ·  view source on GitHub ↗

Materialize the `Constant`. If this entry was built via [`Self::from_constant`], returns the pre-populated cached `Arc` (zero-cost clone). Otherwise parses fresh from `bytes` on every call and returns a new `Arc` without storing it — see the module-level "Cache policy" docs for why.

(&self)

Source from the content-addressed store, hash-verified

148 /// one hash per entry per load, not per call). Used by
149 /// `Env::get_anon` so env parse time does not pay one content hash
150 /// per constant.
151 pub fn from_bytes_deferred(bytes: Arc<[u8]>, addr: Address) -> Self {
152 LazyConstant {
153 bytes: BytesSource::Heap(bytes),
154 cache: None,
155 pending_addr: Some(addr),
156 verified: Arc::new(AtomicBool::new(false)),
157 }
158 }
159
160 /// Construct from a memory-mapped window. The `Arc<Mmap>` keeps
161 /// the underlying mapping alive; cloning the `LazyConstant` only
162 /// bumps the refcount.
163 ///
164 /// Used by `Env::get_anon_mmap` to avoid heap-copying the on-disk
165 /// byte stream — the OS page cache is the source of truth.
166 pub fn from_mmap_slice(mmap: Arc<Mmap>, offset: usize, len: usize) -> Self {
167 LazyConstant {

Callers 5

trailing_bytes_rejectedFunction · 0.45
mmap_slice_roundtripsFunction · 0.45

Calls 3

as_sliceMethod · 0.80
cloneMethod · 0.45
is_emptyMethod · 0.45

Tested by 5

trailing_bytes_rejectedFunction · 0.36
mmap_slice_roundtripsFunction · 0.36