bomboni_request crate provides utilities for parsing and validating API requests, particularly focusing on list and search operations following Google AIP standards. It includes filter expression parsing, ordering, query building, and SQL generation.
Core Types
Filter
Filter expression parser following Google AIP-160 standard.Methods
parse(source: &str) -> FilterResult<Self>- Parses a filter from a source stringevaluate<T: SchemaMapped>(&self, item: &T) -> Option<Value>- Evaluates the filter against an itemvalidate(&self, schema: &Schema, schema_functions: Option<&FunctionSchemaMap>) -> FilterResult<()>- Validates filter against schemalen(&self) -> usize- Returns the length of the filteris_empty(&self) -> bool- Checks if the filter is emptyadd_conjunction(&mut self, other: Self)- Adds a conjunction to the filteradd_disjunction(&mut self, other: Self)- Adds a disjunction to the filter
Filter Grammar
Supported operators:- Comparison:
<,<=,>,>=,=,!= - Has operator:
: - Logical:
AND,OR,NOT - Parentheses for grouping:
(,)
- Strings:
"value" - Numbers:
42,3.14 - Booleans:
true,false - Timestamps: RFC3339 format
- Wildcards:
*
FilterComparator
Comparison operators for filters.Ordering
Query ordering specification.Methods
new(terms: Vec<OrderingTerm>) -> Self- Creates a new orderingparse(source: &str) -> OrderingResult<Self>- Parses an ordering stringevaluate<T: SchemaMapped>(&self, lhs: &T, rhs: &T) -> Option<cmp::Ordering>- Evaluates ordering between two itemsvalidate(&self, schema: &Schema) -> OrderingResult<()>- Validates the ordering against a schema
OrderingTerm
A single ordering term.OrderingDirection
Sort direction.Query Builders
ListQuery
Represents a list query for paginated, filtered, and ordered results following Google AIP-132.ListQueryBuilder
Builder for list queries with schema validation.Methods
new(schema, schema_functions, options, page_token_builder) -> Self- Creates a new list query builderbuild(page_size, page_token, filter, ordering) -> QueryResult<ListQuery>- Builds a list querybuild_next_page_token<T: SchemaMapped>(query, next_item) -> QueryResult<String>- Builds the next page token
ListQueryConfig
Configuration for list query builder.SearchQuery
Represents a search query with text search support.SearchQueryBuilder
Builder for search queries.Methods
new(schema, schema_functions, options, page_token_builder) -> Self- Creates a new search query builderbuild(query, page_size, page_token, filter, ordering) -> QueryResult<SearchQuery>- Builds a search querybuild_next_page_token<T: SchemaMapped>(query, next_item) -> QueryResult<String>- Builds the next page token
SearchQueryConfig
Configuration for search query builder.Page Tokens
FilterPageToken
A page token containing a filter for pagination.PageTokenBuilder
Trait for building and parsing page tokens.Page Token Implementations
PlainPageTokenBuilder- Plain text page tokensBase64PageTokenBuilder- Base64 encoded page tokensAes256PageTokenBuilder- AES256 encrypted page tokensRsaPageTokenBuilder- RSA encrypted page tokens
SQL Generation
SqlFilterBuilder
Builder for generating SQL WHERE clauses from filters.Methods
new(dialect: SqlDialect, schema: &Schema) -> Self- Creates a new SQL filter builderset_schema_functions(&mut self, schema_functions: &FunctionSchemaMap) -> &mut Self- Sets the schema functionsset_rename_map(&mut self, rename_map: &SqlRenameMap) -> &mut Self- Sets the rename mapset_document_offset(&mut self, offset: usize) -> &mut Self- Sets the document offsetcase_insensitive_like(&mut self) -> &mut Self- Enables case insensitive likeset_argument_style(&mut self, argument_style: SqlArgumentStyle) -> &mut Self- Sets the argument stylebuild(&mut self, filter: &Filter) -> FilterResult<(String, Vec<Value>)>- Builds a SQL filter
SqlDialect
SQL dialect for generation.SqlArgumentStyle
SQL argument placeholder style.SqlRenameMap
Rename map for SQL generation.Schema
Schema
Schema for query validation.Methods
get_member(&self, name: &str) -> Option<&MemberSchema>- Gets member schema by nameget_field(&self, name: &str) -> Option<&FieldMemberSchema>- Gets field schema by name
MemberSchema
Schema member type.FieldMemberSchema
Field member schema.Methods
new(value_type: ValueType) -> Self- Creates a new field member schemanew_ordered(value_type: ValueType) -> Self- Creates a new ordered field member schemanew_repeated(value_type: ValueType) -> Self- Creates a new repeated field member schema
ValueType
Value type for schema validation.SchemaMapped
Trait for types that can be mapped to schema values.Value
Query value representation.Methods
value_type(&self) -> Option<ValueType>- Gets the value typeparse(pair: &Pair<Rule>) -> FilterResult<Self>- Parses a value from a pest pair