| 467 | } |
| 468 | |
| 469 | pub trait Codec<T: 'static>: 'static { |
| 470 | fn field_type(type_resolver: &TypeResolver) -> Result<FieldType, Error>; |
| 471 | |
| 472 | #[inline(always)] |
| 473 | fn reserved_space() -> usize { |
| 474 | std::mem::size_of::<T>() |
| 475 | } |
| 476 | |
| 477 | fn write_field(value: &T, context: &mut WriteContext) -> Result<(), Error>; |
| 478 | |
| 479 | fn read_field(context: &mut ReadContext) -> Result<T, Error>; |
| 480 | |
| 481 | #[inline(always)] |
| 482 | fn read_compatible( |
| 483 | context: &mut ReadContext, |
| 484 | local_field_type: &FieldType, |
| 485 | remote_field_type: &FieldType, |
| 486 | ) -> Result<Option<T>, Error> { |
| 487 | if field_types_compatible(local_field_type, remote_field_type) |
| 488 | || local_field_type.compatible_shape_match(remote_field_type) |
| 489 | { |
| 490 | return Self::read_field_with_type(context, remote_field_type).map(Some); |
| 491 | } |
| 492 | super::scalar_conversion::read_scalar_field::<T, Self>( |
| 493 | context, |
| 494 | local_field_type, |
| 495 | remote_field_type, |
| 496 | ) |
| 497 | } |
| 498 | |
| 499 | fn write_data(value: &T, context: &mut WriteContext) -> Result<(), Error>; |
| 500 | |
| 501 | fn read_data(context: &mut ReadContext) -> Result<T, Error>; |
| 502 | |
| 503 | #[inline(always)] |
| 504 | fn read_data_with_type( |
| 505 | context: &mut ReadContext, |
| 506 | _remote_data_type: &FieldType, |
| 507 | ) -> Result<T, Error> { |
| 508 | Self::read_data(context) |
| 509 | } |
| 510 | |
| 511 | #[inline(always)] |
| 512 | fn read_data_with_type_info( |
| 513 | context: &mut ReadContext, |
| 514 | type_info: &Rc<crate::TypeInfo>, |
| 515 | ) -> Result<T, Error> { |
| 516 | Self::read_with_type_info(context, RefMode::None, type_info.clone()) |
| 517 | } |
| 518 | |
| 519 | #[inline(always)] |
| 520 | fn type_info_exact( |
| 521 | _context: &ReadContext, |
| 522 | _type_info: &Rc<crate::TypeInfo>, |
| 523 | ) -> Result<bool, Error> { |
| 524 | Ok(false) |
| 525 | } |
| 526 |
no outgoing calls
no test coverage detected