Skip to content

Replace LinkType trait with LinkReference from platform-num (Numbers) #30

Closed

Description

@konard

Summary

Replace the local LinkType trait definition in platform-trees with LinkReference from platform-num (Numbers), unifying the trait hierarchy across the platform ecosystem.

Current state

platform-trees 0.3.3 defines LinkType as:

pub trait LinkType: Number + Unsigned + Sized + TryFrom<u8> + FromPrimitive {
    fn funty(n: u8) -> Self;
}

This already depends on platform-num for the Number trait and num-traits for Unsigned and FromPrimitive. The funty() method provides conversion from u8 for creating small constants.

Meanwhile, platform-data uses funty::Unsigned (from the funty crate) instead of num_traits::Unsigned. These are different traits, making it impossible to write unified generic code that works with both data::LinkType and trees::LinkType.

Proposed change

Once linksplatform/Numbers#144 is implemented (adding TryFrom/TryInto bounds and funty() method to LinkReference), refactor LinkType to:

pub trait LinkType: LinkReference {}

Or simply replace LinkType with LinkReference throughout the crate.

This works because LinkReference (after Numbers#144) will be a superset of the current trees::LinkType bounds:

  • Number ✅ (already in LinkReference)
  • Unsigned ✅ (already in LinkReference)
  • Sized ✅ (will be in LinkReference)
  • TryFrom<u8> ✅ (will be added in Numbers#144)
  • FromPrimitive ✅ (already in LinkReference)
  • funty() method ✅ (will be added in Numbers#144)

Benefits

  1. Eliminates trait duplication — no more separate trees::LinkType vs data::LinkType
  2. Enables unified generic code — downstream crates like doublets-rs can use a single T: LinkReference bound
  3. Reduces maintenance — trait definition is centralized in platform-num

Related

Activity

  1. konard commented on Apr 14, 2026

    @konard
    MemberAuthor

    Update from Numbers#144 (platform-num)

    LinkReference in platform-num now includes all bounds needed by trees::LinkType:

    trees-rs LinkType requirement LinkReference status
    Number ✅ Already included
    num_traits::Unsigned ✅ Already included
    Sized ✅ Added
    TryFrom<u8> ✅ Added (all 12 integer types)
    FromPrimitive ✅ Already included
    funty(n: u8) -> Self method ✅ Replaced by from_byte(n: u8) -> Self

    Key decisions

    • funty() → from_byte(): The method was renamed to remove the cryptic funty crate reference. from_byte is descriptive and avoids name collision with FromPrimitive::from_u8.
    • u128 support: LinkReference is now explicitly supported for u8, u16, u32, u64, u128, usize — enabling very large link address spaces in doublets-rs.
    • Migration path: Replace T: trees::LinkType with T: LinkReference, and replace T::funty(n) calls with T::from_byte(n).

    See: linksplatform/Numbers#145

    We need to download all logs and data related about the issue to this repository, make sure we compile that data to ./docs/case-studies/issue-{id} folder, and use it to do deep case study analysis (also make sure to search online for additional facts and data), in which we will reconstruct timeline/sequence of events, list of each and all requirements from the issue, find root causes of the each problem, and propose possible solutions and solution plans for each requirement (we should also check known existing components/libraries, that solve similar problem or can help in solutions).

    If there is not enough data to find actual root cause, add debug output and verbose mode if not present, that will allow us to find root cause on next iteration.

    If issue related to any other repository/project, where we can report issues on GitHub, please do so. Each issue must contain reproducible examples, workarounds and suggestions for fix the issue in code.

  2. added
    bug
    on Apr 14, 2026
  3. added theissue type on Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions