adriangb commented on code in PR #7718: URL: https://github.com/apache/arrow-rs/pull/7718#discussion_r2159410669
########## parquet-variant/src/variant.rs: ########## @@ -29,6 +29,57 @@ mod list; mod metadata; mod object; +const MAX_SHORT_STRING_SIZE: usize = 0x3F; + +/// A Variant [`ShortString`] +/// +/// This implementation is a zero cost wrapper over `&str` that ensures +/// the length of the underlying string is a valid Variant short string (63 bytes or less) +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct ShortString<'a>(pub(crate) &'a str); + +impl<'a> ShortString<'a> { + /// Attempts to interpret `value` as a variant short string value. + /// + /// # Validation + /// + /// This constructor verifies that `value` is shorter than or equal to `MAX_SHORT_STRING_SIZE` + pub fn try_new(value: &'a str) -> Result<Self, ArrowError> { + if value.len() > MAX_SHORT_STRING_SIZE { Review Comment: Worth adding a comment here that we are indeed supposed to check bytes and not characters, that's a common confusion with "string length" -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org