blackmwk commented on code in PR #2970: URL: https://github.com/apache/iceberg-rust/pull/2970#discussion_r3733300336
########## crates/property-macro/README.md: ########## @@ -0,0 +1,342 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +# Iceberg property derive macro + +`Properties` generates inherent methods for reading and writing a typed struct +from a flat `HashMap<String, String>`. It deliberately does not implement +`Default`, `Serialize`, `Deserialize`, or any other trait. + +## Generated methods + +For every annotated struct, `#[derive(Properties)]` generates these inherent +methods: + +```text +impl MyProperties { + pub fn from_properties( + properties: &HashMap<String, String>, + ) -> Result<Self, String>; + + pub fn write_properties( + &self, + properties: &mut HashMap<String, String>, + ) -> Result<(), String>; +} +``` + +`from_properties` parses every modeled property, uses its annotated default +when absent, and returns an error containing the primary property key when a +value is invalid. Unknown keys are ignored. + +`write_properties` updates an existing map. It removes modeled keys whose +values equal their annotated defaults, writes non-default values as strings, Review Comment: The motivation is that I want to avoid writing all properties everytime, but I think your concerns is correct, default property values are not part of spec. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
