Skip to main content

rest_sql/
mapper.rs

1/// Transforms a logical field name to its storage representation.
2/// Implement this in drivers to handle JSONB paths, column aliases, etc.
3pub trait FieldMapper {
4    fn map<'a>(&self, field: &'a str) -> std::borrow::Cow<'a, str>;
5}
6
7/// Identity mapper — field name is used as-is.
8#[derive(Debug, Clone, Default)]
9pub struct IdentityMapper;
10
11impl FieldMapper for IdentityMapper {
12    fn map<'a>(&self, field: &'a str) -> std::borrow::Cow<'a, str> {
13        std::borrow::Cow::Borrowed(field)
14    }
15}