bomboni_request_derive crate provides procedural macros for parsing and validating request types, particularly for converting between protobuf messages and domain models.
Parse Derive Macro
TheParse derive macro generates code for converting between different data representations with validation and error handling.
Struct-Level Attributes
source
Specifies the source type to parse from (required).write
GeneratesFrom trait implementation for converting back to source type.
serialize_as / deserialize_as / serde_as
Generates serde implementations for the source type.request
Marks the message as a request for enhanced error handling.tagged_union
Creates tagged union from a oneof field.Crate Path Customization
Field-Level Attributes
source
Specifies the source field name or path.source_field
Indicates the source field name is the same as the target field name.skip
Skips parsing this field entirely.keep
Keeps the source and target fields identical without parsing.keep_primitive
Parses only the container, keeping primitive types unchanged.unspecified
Allows unspecified enum values and empty strings.extract
Defines extraction steps for transforming field values.wrapper
Parses protobuf wrapper types.StringValue→StringBoolValue→boolFloatValue→f32DoubleValue→f64Int32Value→i8,i16,i32UInt32Value→u8,u16,u32Int64Value→i64,isizeUInt64Value→u64,usize
oneof
Parses from a protobuf oneof field.enumeration
Parses enum fromi32 value.
regex
Validates string against a regular expression.timestamp
Parsesgoogle.protobuf.Timestamp into UtcDateTime.
try_from
Converts field usingTryFrom or TryInto.
convert
Uses custom conversion functions.derive
Uses derived parsing implementation for custom transformations.resource
Parses resource metadata fields.list_query
Parses list query parameters.search_query
Parses search query parameters.field_mask
Parses field only if field mask allows it.Complex Examples
Basic Struct Parsing
Optional Fields and Extraction
Oneof and Tagged Unions
Collections
Wrapper Types
Query Parsing
Derived Fields
Helper Macros
parse_resource_name
Parses resource names into typed segments.derived_map
Creates derived map types for complex field transformations.Error Handling
The Parse macro generates code that usesRequestResult<T> which wraps errors with path information for debugging.
CommonError::RequiredFieldMissing- Required field is empty or NoneCommonError::InvalidStringFormat- String doesn’t match regexCommonError::InvalidEnumValue- Invalid enum discriminantCommonError::InvalidNumericValue- Numeric parsing failedPathError- Error with field path context