Skip to main content

Uid

Struct Uid 

Source
pub struct Uid(pub u64);
Expand description

A stable identity for one node, independent of where it sits.

§Why the tree needs one

Every other handle on a node in this system is its position: the trace key (node/0/1), and therefore the trace address of every knob on it, and therefore every lock, every remembered hand position, every selection. That is fine until the structure moves. Insert one filter at the top of a chain and every key below it shifts by one segment; delete a mixer branch and the survivor is re-rooted; run one generation of refinement and the tree is rebuilt from a trace with no memory of the object graph at all. Under positional identity the only honest response to a structural edit is to throw the UI’s state away — which is exactly what the workbench used to do, with the comment “structure changed — locks cleared” — and that destroys the loop the graph editor exists to serve: build a routing by hand, pin it, and breed around it.

A Uid is minted once, travels with the node through clones, splices and refinement, and is dropped only when the node itself is.

§It is deliberately invisible to the model

uid is UI identity, nothing else. It must never reach the generative model, the featurizer, the compiler, or anything content-addressed, because two patches that differ only in uids are the same patch and every one of those systems is entitled to say so:

  • Equality ignores it. PartialEq here is true unconditionally, so the derived PartialEq on AudioNode/PatchTree keeps comparing patches by content. The engine’s pool dedup (self.pool.iter().any(|c| c.tree == end)) and refinement’s own “did this walk move at all” (current != *seed) are both that comparison, and both would break the moment a fresh uid could make two identical trees differ.
  • Hashing ignores it, for the same reason and so the two stay coherent.
  • It is skipped in JSON when unset, and auracle_features::cache::canonical_tree_json clears uids before hashing, so the render memo’s content address is byte-identical to what it was before uids existed. A cache key that moved with the UI’s bookkeeping would miss on every refinement step and invalidate every persisted row.
  • It is not a choice site. crate::genome neither encodes nor decodes it, so to_trace/from_trace round-trips carry no uid — which is why PatchTree::inherit_uids exists.

§Uid::NEW and settling

Construction sites write Uid::NEW (zero, “unset”) rather than minting eagerly. The prior samples thousands of trees per refinement walk and all but one are thrown away; minting there would burn identities for nothing and make the counter’s value depend on how much search ran. Instead a tree is settledPatchTree::ensure_uids — at the few points where it becomes something a person can point at: admitted to the pool, adopted onto the bench, restored from a save. Everything before that is anonymous.

Tuple Fields§

§0: u64

Implementations§

Source§

impl Uid

Source

pub const NEW: Uid

The unset identity: a node that has not been settled yet.

Source

pub fn mint() -> Uid

Mint a fresh identity.

Source

pub fn observe(id: Uid)

Note that this identity already exists, so the mint never reissues it.

The counter is per process, and a restored session is the case that makes that a problem rather than a detail: a save carries the uids it was written with (that is the entire point — a hand-placed layout has to survive a reload), but a fresh page load starts the counter at 1. Insert one module into a restored patch and the mint would hand out an id that tree is already using, and two nodes would answer to one lock. So every identity the engine sees pushes the counter past itself, and a restore — which settles the whole bank on the way in — leaves it above every id in the save.

Source

pub fn is_new(&self) -> bool

Whether this node still needs an identity.

Trait Implementations§

Source§

impl Clone for Uid

Source§

fn clone(&self) -> Uid

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Uid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Uid

Source§

fn default() -> Uid

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Uid

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for Uid

Source§

fn hash<H: Hasher>(&self, _: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Uid

Source§

fn eq(&self, _: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Uid

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for Uid

Source§

impl Eq for Uid

Auto Trait Implementations§

§

impl Freeze for Uid

§

impl RefUnwindSafe for Uid

§

impl Send for Uid

§

impl Sync for Uid

§

impl Unpin for Uid

§

impl UnsafeUnpin for Uid

§

impl UnwindSafe for Uid

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,