use super::*;
pub struct StructNameSpace(pub(crate) Expr);
impl StructNameSpace {
pub fn field_by_index(self, index: i64) -> Expr {
self.0
.map_private(FunctionExpr::StructExpr(StructFunction::FieldByIndex(
index,
)))
.with_function_options(|mut options| {
options.allow_rename = true;
options
})
}
pub fn field_by_name(self, name: &str) -> Expr {
self.0
.map_private(FunctionExpr::StructExpr(StructFunction::FieldByName(
Arc::from(name),
)))
.with_function_options(|mut options| {
options.allow_rename = true;
options
})
}
pub fn rename_fields(self, names: Vec<String>) -> Expr {
self.0
.map_private(FunctionExpr::StructExpr(StructFunction::RenameFields(
Arc::from(names),
)))
}
#[cfg(feature = "json")]
pub fn json_encode(self) -> Expr {
self.0
.map_private(FunctionExpr::StructExpr(StructFunction::JsonEncode))
}
}