Skip to content
This repository has been archived by the owner on Nov 12, 2023. It is now read-only.

Implement 'wrapper' enum types #32

Closed
Antikyth opened this issue Jan 2, 2023 · 4 comments
Closed

Implement 'wrapper' enum types #32

Antikyth opened this issue Jan 2, 2023 · 4 comments
Assignees
Labels
help wanted Extra attention is needed task An essential task for a planned milestone.

Comments

@Antikyth
Copy link
Collaborator

Antikyth commented Jan 2, 2023

E.g. the CreateWindow request has the field visual, where 0 means CopyFromParent, and any other value means a VisualId. This will need to therefore be something like:

pub enum Inheritable<T> {
    CopyFromParent,
    Uninherited(T),
}

where Uninherited(T) writes no discriminant, and CopyFromParent, in the case of VisualIds, is written as a u32 value (as are VisualIds).

Thoughts

May be able to take advantage of the fact that VisualIds actually wrap u32 values. Traits could be implemented for Inheritable<T> where T wraps a u32 value (what bound that could be, I'm not sure; T: From<u32> wouldn't work because of the fact that it would be possible to implement From<u16>, etc., for T as well).

@Antikyth Antikyth added help wanted Extra attention is needed task An essential task for a planned milestone. labels Jan 2, 2023
@Antikyth Antikyth added this to the 0.1.0 milestone Jan 2, 2023
@Antikyth
Copy link
Collaborator Author

Antikyth commented Jan 2, 2023

This is one of the most challenging unsolved problems in XRB: how to do this in a decent way.

@Antikyth Antikyth pinned this issue Jan 2, 2023
@Antikyth
Copy link
Collaborator Author

Currently this is being done with a Wrapper trait in XRBK. There may or may not be a better way. I will leave this issue open for now in case a better way is found.

@Antikyth Antikyth unpinned this issue Jan 10, 2023
@Antikyth
Copy link
Collaborator Author

See #45 and #53 draft PRs.

@Antikyth Antikyth self-assigned this Jan 16, 2023
@Antikyth
Copy link
Collaborator Author

Completed in #69.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed task An essential task for a planned milestone.
Projects
Archived in project
Development

No branches or pull requests

1 participant