Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ULE trait should work on not just slices #5600

Open
sffc opened this issue Sep 25, 2024 · 0 comments
Open

ULE trait should work on not just slices #5600

sffc opened this issue Sep 25, 2024 · 0 comments
Labels
C-zerovec Component: Yoke, ZeroVec, DataBake discuss Discuss at a future ICU4X-SC meeting
Milestone

Comments

@sffc
Copy link
Member

sffc commented Sep 25, 2024

This issue is intended to be discussed in the context of zerovec 1.0 / holistic design

I've thought this for a while but I wasn't able to find an issue for it. The trait is currently:

pub unsafe trait ULE
where
    Self: Sized + Copy + 'static,
{
    // Required method
    fn validate_byte_slice(bytes: &[u8]) -> Result<(), UleError>;

    // Provided methods
    fn parse_byte_slice(bytes: &[u8]) -> Result<&[Self], UleError> { ... }
    unsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &[Self] { ... }
    fn as_byte_slice(slice: &[Self]) -> &[u8] { ... }
}

I think we should add:

  • validate_chunk(chunk: [u8; size_of::<Self>]) -> Result<(), UleError> (required method)
  • parse_chunk (provided method)
  • from_chunk_unchecked (provided method)

and then change validate_byte_slice to be a provided method.

@sffc sffc added discuss Discuss at a future ICU4X-SC meeting C-zerovec Component: Yoke, ZeroVec, DataBake labels Sep 25, 2024
@sffc sffc added this to the Utilities 1.0 milestone Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-zerovec Component: Yoke, ZeroVec, DataBake discuss Discuss at a future ICU4X-SC meeting
Projects
None yet
Development

No branches or pull requests

1 participant