Skip to content

Refactor CidVariant Implementation #3367

@jdjaustin

Description

@jdjaustin

Refactor CidVariant to use naming convention SmallCid and hide enum details from users.

"Also, I think this is the layout we want:

/// Save space on common CID types
pub struct SmallCid(SmallCidInner);

impl SmallCid {
    pub fn cid(&self) -> Cid { ... }
}

impl From<Cid> for SmallCid { ... }
impl From<SmallCid> for Cid { ... }
impl PartialEq<Cid> for SmallCid { ... }

enum SmallCidInner {
    DagCborV1([u8; 32]),
    Heap(Box<Cid>)
}

Users shouldn't be able to see the enum variant"

Originally posted by @aatifsyed in #3275 (comment)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions