(
&self,
array: &'formatter dyn Array,
options: &FormatOptions<'formatter>,
field: Option<&'formatter Field>,
)
| 1253 | |
| 1254 | impl ArrayFormatterFactory for TestFormatters { |
| 1255 | fn create_array_formatter<'formatter>( |
| 1256 | &self, |
| 1257 | array: &'formatter dyn Array, |
| 1258 | options: &FormatOptions<'formatter>, |
| 1259 | field: Option<&'formatter Field>, |
| 1260 | ) -> Result<Option<ArrayFormatter<'formatter>>, ArrowError> { |
| 1261 | if field |
| 1262 | .map(|f| f.extension_type_name() == Some("my_money")) |
| 1263 | .unwrap_or(false) |
| 1264 | { |
| 1265 | // We assume that my_money always is an Int32. |
| 1266 | let array = array.as_primitive(); |
| 1267 | let display_index = Box::new(MyMoneyFormatter { |
| 1268 | array, |
| 1269 | options: options.clone(), |
| 1270 | }); |
| 1271 | return Ok(Some(ArrayFormatter::new(display_index, options.safe()))); |
| 1272 | } |
| 1273 | |
| 1274 | if array.data_type() == &DataType::Int32 { |
| 1275 | let array = array.as_primitive(); |
| 1276 | let display_index = Box::new(MyInt32Formatter { |
| 1277 | array, |
| 1278 | options: options.clone(), |
| 1279 | }); |
| 1280 | return Ok(Some(ArrayFormatter::new(display_index, options.safe()))); |
| 1281 | } |
| 1282 | |
| 1283 | Ok(None) |
| 1284 | } |
| 1285 | } |
| 1286 | |
| 1287 | /// A format that will append a "€" sign to the end of the Int32 values. |
no test coverage detected