| 635 | } |
| 636 | |
| 637 | Status array_open_deserialize( |
| 638 | Array* array, |
| 639 | SerializationType serialize_type, |
| 640 | span<const char> serialized_buffer) { |
| 641 | try { |
| 642 | switch (serialize_type) { |
| 643 | case SerializationType::JSON: { |
| 644 | ::capnp::JsonCodec json; |
| 645 | json.handleByAnnotation<capnp::ArrayOpen>(); |
| 646 | ::capnp::MallocMessageBuilder message_builder; |
| 647 | capnp::ArrayOpen::Builder array_open_builder = |
| 648 | message_builder.initRoot<capnp::ArrayOpen>(); |
| 649 | utils::decode_json_message(serialized_buffer, array_open_builder, json); |
| 650 | capnp::ArrayOpen::Reader array_open_reader = |
| 651 | array_open_builder.asReader(); |
| 652 | RETURN_NOT_OK(array_open_from_capnp(array_open_reader, array)); |
| 653 | break; |
| 654 | } |
| 655 | case SerializationType::CAPNP: { |
| 656 | const auto mBytes = |
| 657 | reinterpret_cast<const kj::byte*>(serialized_buffer.data()); |
| 658 | ::capnp::FlatArrayMessageReader reader(kj::arrayPtr( |
| 659 | reinterpret_cast<const ::capnp::word*>(mBytes), |
| 660 | serialized_buffer.size() / sizeof(::capnp::word))); |
| 661 | capnp::ArrayOpen::Reader array_open_reader = |
| 662 | reader.getRoot<capnp::ArrayOpen>(); |
| 663 | RETURN_NOT_OK(array_open_from_capnp(array_open_reader, array)); |
| 664 | break; |
| 665 | } |
| 666 | default: { |
| 667 | return LOG_STATUS(Status_SerializationError( |
| 668 | "Error deserializing array open; Unknown serialization type " |
| 669 | "passed")); |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | } catch (kj::Exception& e) { |
| 674 | return LOG_STATUS(Status_SerializationError( |
| 675 | "Error deserializing array open; kj::Exception: " + |
| 676 | std::string(e.getDescription().cStr()))); |
| 677 | } catch (std::exception& e) { |
| 678 | return LOG_STATUS(Status_SerializationError( |
| 679 | "Error deserializing array open; exception " + std::string(e.what()))); |
| 680 | } |
| 681 | |
| 682 | return Status::Ok(); |
| 683 | } |
| 684 | |
| 685 | #else |
| 686 |
no test coverage detected