1use super::Address;
2use super::Digest;
3use super::Identifier;
4use super::ObjectId;
5
6#[derive(Eq, PartialEq, Clone, Debug)]
18#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
19pub enum ExecutionStatus {
20 Success,
22
23 Failure {
29 error: ExecutionError,
31 #[cfg_attr(feature = "proptest", map(|x: Option<u16>| x.map(Into::into)))]
33 command: Option<u64>,
34 },
35}
36
37#[derive(Eq, PartialEq, Clone, Debug)]
121#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
122pub enum ExecutionError {
123 InsufficientGas,
128 InvalidGasObject,
130 InvariantViolation,
132 FeatureNotYetSupported,
134 ObjectTooBig {
136 object_size: u64,
137 max_object_size: u64,
138 },
139 PackageTooBig {
141 object_size: u64,
142 max_object_size: u64,
143 },
144 CircularObjectOwnership { object: ObjectId },
146
147 InsufficientCoinBalance,
152 CoinBalanceOverflow,
154
155 PublishErrorNonZeroAddress,
161
162 SuiMoveVerificationError,
164
165 MovePrimitiveRuntimeError { location: Option<MoveLocation> },
172 MoveAbort { location: MoveLocation, code: u64 },
174 VmVerificationOrDeserializationError,
176 VmInvariantViolation,
178
179 FunctionNotFound,
184 ArityMismatch,
187 TypeArityMismatch,
190 NonEntryFunctionInvoked,
192 CommandArgumentError {
194 argument: u16,
195 kind: CommandArgumentError,
196 },
197 TypeArgumentError {
199 type_argument: u16,
201 kind: TypeArgumentError,
202 },
203 UnusedValueWithoutDrop { result: u16, subresult: u16 },
205 InvalidPublicFunctionReturnType { index: u16 },
208 InvalidTransferObject,
210
211 EffectsTooLarge { current_size: u64, max_size: u64 },
216
217 PublishUpgradeMissingDependency,
219
220 PublishUpgradeDependencyDowngrade,
226
227 PackageUpgradeError { kind: PackageUpgradeError },
229
230 WrittenObjectsTooLarge {
232 object_size: u64,
233 max_object_size: u64,
234 },
235
236 CertificateDenied,
238
239 SuiMoveVerificationTimedout,
241
242 SharedObjectOperationNotAllowed,
244
245 InputObjectDeleted,
247
248 ExecutionCanceledDueToSharedObjectCongestion { congested_objects: Vec<ObjectId> },
250
251 AddressDeniedForCoin { address: Address, coin_type: String },
253
254 CoinTypeGlobalPause { coin_type: String },
256
257 ExecutionCanceledDueToRandomnessUnavailable,
259
260 MoveVectorElemTooBig {
264 value_size: u64,
265 max_scaled_size: u64,
266 },
267
268 MoveRawValueTooBig {
272 value_size: u64,
273 max_scaled_size: u64,
274 },
275
276 InvalidLinkage,
278}
279
280#[derive(Eq, PartialEq, Clone, Debug)]
290#[cfg_attr(
291 feature = "serde",
292 derive(serde_derive::Serialize, serde_derive::Deserialize)
293)]
294#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
295pub struct MoveLocation {
296 pub package: ObjectId,
298
299 pub module: Identifier,
301
302 pub function: u16,
304
305 pub instruction: u16,
308
309 pub function_name: Option<Identifier>,
311}
312
313#[derive(Eq, PartialEq, Clone, Debug)]
347#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
348pub enum CommandArgumentError {
349 TypeMismatch,
351
352 InvalidBcsBytes,
354
355 InvalidUsageOfPureArgument,
357
358 InvalidArgumentToPrivateEntryFunction,
361
362 IndexOutOfBounds { index: u16 },
364
365 SecondaryIndexOutOfBounds { result: u16, subresult: u16 },
367
368 InvalidResultArity { result: u16 },
371
372 InvalidGasCoinUsage,
375
376 InvalidValueUsage,
381
382 InvalidObjectByValue,
384
385 InvalidObjectByMutRef,
387
388 SharedObjectOperationNotAllowed,
391
392 InvalidArgumentArity,
395}
396
397#[derive(Eq, PartialEq, Clone, Debug)]
419#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
420pub enum PackageUpgradeError {
421 UnableToFetchPackage { package_id: ObjectId },
423
424 NotAPackage { object_id: ObjectId },
426
427 IncompatibleUpgrade,
429
430 DigestDoesNotMatch { digest: Digest },
432
433 UnknownUpgradePolicy { policy: u8 },
435
436 PackageIdDoesNotMatch {
438 package_id: ObjectId,
439 ticket_id: ObjectId,
440 },
441}
442
443#[derive(Eq, PartialEq, Clone, Copy, Debug)]
455#[cfg_attr(
456 feature = "serde",
457 derive(serde_derive::Serialize, serde_derive::Deserialize),
458 serde(rename_all = "snake_case")
459)]
460#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
461pub enum TypeArgumentError {
462 TypeNotFound,
464
465 ConstraintNotSatisfied,
467}
468
469#[cfg(feature = "serde")]
470#[cfg_attr(doc_cfg, doc(cfg(feature = "serde")))]
471mod serialization {
472 use super::*;
473
474 use serde::Deserialize;
475 use serde::Deserializer;
476 use serde::Serialize;
477 use serde::Serializer;
478
479 #[derive(serde_derive::Serialize, serde_derive::Deserialize)]
480 #[serde(rename = "ExecutionStatus")]
481 struct ReadableExecutionStatus {
482 success: bool,
483 #[serde(skip_serializing_if = "Option::is_none")]
484 status: Option<FailureStatus>,
485 }
486
487 #[derive(serde_derive::Serialize, serde_derive::Deserialize)]
488 struct FailureStatus {
489 error: ExecutionError,
490 #[serde(skip_serializing_if = "Option::is_none")]
491 command: Option<u16>,
492 }
493
494 #[derive(serde_derive::Serialize, serde_derive::Deserialize)]
495 enum BinaryExecutionStatus {
496 Success,
497 Failure {
498 error: ExecutionError,
499 command: Option<u64>,
500 },
501 }
502
503 impl Serialize for ExecutionStatus {
504 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
505 where
506 S: Serializer,
507 {
508 if serializer.is_human_readable() {
509 let readable = match self.clone() {
510 ExecutionStatus::Success => ReadableExecutionStatus {
511 success: true,
512 status: None,
513 },
514 ExecutionStatus::Failure { error, command } => ReadableExecutionStatus {
515 success: false,
516 status: Some(FailureStatus {
517 error,
518 command: command.map(|c| c as u16),
519 }),
520 },
521 };
522 readable.serialize(serializer)
523 } else {
524 let binary = match self.clone() {
525 ExecutionStatus::Success => BinaryExecutionStatus::Success,
526 ExecutionStatus::Failure { error, command } => {
527 BinaryExecutionStatus::Failure { error, command }
528 }
529 };
530 binary.serialize(serializer)
531 }
532 }
533 }
534
535 impl<'de> Deserialize<'de> for ExecutionStatus {
536 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
537 where
538 D: Deserializer<'de>,
539 {
540 if deserializer.is_human_readable() {
541 let ReadableExecutionStatus { success, status } =
542 Deserialize::deserialize(deserializer)?;
543 match (success, status) {
544 (true, None) => Ok(ExecutionStatus::Success),
545 (false, Some(FailureStatus { error, command })) => {
546 Ok(ExecutionStatus::Failure {
547 error,
548 command: command.map(Into::into),
549 })
550 }
551 (true, Some(_)) | (false, None) => {
553 Err(serde::de::Error::custom("invalid execution status"))
554 }
555 }
556 } else {
557 BinaryExecutionStatus::deserialize(deserializer).map(|readable| match readable {
558 BinaryExecutionStatus::Success => Self::Success,
559 BinaryExecutionStatus::Failure { error, command } => {
560 Self::Failure { error, command }
561 }
562 })
563 }
564 }
565 }
566
567 #[derive(serde_derive::Serialize, serde_derive::Deserialize)]
568 #[serde(tag = "error", rename_all = "snake_case")]
569 enum ReadableExecutionError {
570 InsufficientGas,
571 InvalidGasObject,
572 InvariantViolation,
573 FeatureNotYetSupported,
574 ObjectTooBig {
575 #[serde(with = "crate::_serde::ReadableDisplay")]
576 object_size: u64,
577 #[serde(with = "crate::_serde::ReadableDisplay")]
578 max_object_size: u64,
579 },
580 PackageTooBig {
581 #[serde(with = "crate::_serde::ReadableDisplay")]
582 object_size: u64,
583 #[serde(with = "crate::_serde::ReadableDisplay")]
584 max_object_size: u64,
585 },
586 CircularObjectOwnership {
587 object: ObjectId,
588 },
589 InsufficientCoinBalance,
590 CoinBalanceOverflow,
591 PublishErrorNonZeroAddress,
592 SuiMoveVerificationError,
593 MovePrimitiveRuntimeError {
594 location: Option<MoveLocation>,
595 },
596 MoveAbort {
597 location: MoveLocation,
598 #[serde(with = "crate::_serde::ReadableDisplay")]
599 code: u64,
600 },
601 VmVerificationOrDeserializationError,
602 VmInvariantViolation,
603 FunctionNotFound,
604 ArityMismatch,
605 TypeArityMismatch,
606 NonEntryFunctionInvoked,
607 CommandArgumentError {
608 argument: u16,
609 kind: CommandArgumentError,
610 },
611 TypeArgumentError {
612 type_argument: u16,
613 kind: TypeArgumentError,
614 },
615 UnusedValueWithoutDrop {
616 result: u16,
617 subresult: u16,
618 },
619 InvalidPublicFunctionReturnType {
620 index: u16,
621 },
622 InvalidTransferObject,
623 EffectsTooLarge {
624 #[serde(with = "crate::_serde::ReadableDisplay")]
625 current_size: u64,
626 #[serde(with = "crate::_serde::ReadableDisplay")]
627 max_size: u64,
628 },
629 PublishUpgradeMissingDependency,
630 PublishUpgradeDependencyDowngrade,
631 PackageUpgradeError {
632 kind: PackageUpgradeError,
633 },
634 WrittenObjectsTooLarge {
635 #[serde(with = "crate::_serde::ReadableDisplay")]
636 object_size: u64,
637 #[serde(with = "crate::_serde::ReadableDisplay")]
638 max_object_size: u64,
639 },
640 CertificateDenied,
641 SuiMoveVerificationTimedout,
642 SharedObjectOperationNotAllowed,
643 InputObjectDeleted,
644 ExecutionCanceledDueToSharedObjectCongestion {
645 congested_objects: Vec<ObjectId>,
646 },
647
648 AddressDeniedForCoin {
649 address: Address,
650 coin_type: String,
651 },
652
653 CoinTypeGlobalPause {
654 coin_type: String,
655 },
656
657 ExecutionCanceledDueToRandomnessUnavailable,
658
659 MoveVectorElemTooBig {
660 value_size: u64,
661 max_scaled_size: u64,
662 },
663
664 MoveRawValueTooBig {
665 value_size: u64,
666 max_scaled_size: u64,
667 },
668
669 InvalidLinkage,
670 }
671
672 #[derive(serde_derive::Serialize, serde_derive::Deserialize)]
673 enum BinaryExecutionError {
674 InsufficientGas,
675 InvalidGasObject,
676 InvariantViolation,
677 FeatureNotYetSupported,
678 ObjectTooBig {
679 object_size: u64,
680 max_object_size: u64,
681 },
682 PackageTooBig {
683 object_size: u64,
684 max_object_size: u64,
685 },
686 CircularObjectOwnership {
687 object: ObjectId,
688 },
689 InsufficientCoinBalance,
690 CoinBalanceOverflow,
691 PublishErrorNonZeroAddress,
692 SuiMoveVerificationError,
693 MovePrimitiveRuntimeError {
694 location: Option<MoveLocation>,
695 },
696 MoveAbort {
697 location: MoveLocation,
698 code: u64,
699 },
700 VmVerificationOrDeserializationError,
701 VmInvariantViolation,
702 FunctionNotFound,
703 ArityMismatch,
704 TypeArityMismatch,
705 NonEntryFunctionInvoked,
706 CommandArgumentError {
707 argument: u16,
708 kind: CommandArgumentError,
709 },
710 TypeArgumentError {
711 type_argument: u16,
712 kind: TypeArgumentError,
713 },
714 UnusedValueWithoutDrop {
715 result: u16,
716 subresult: u16,
717 },
718 InvalidPublicFunctionReturnType {
719 index: u16,
720 },
721 InvalidTransferObject,
722 EffectsTooLarge {
723 current_size: u64,
724 max_size: u64,
725 },
726 PublishUpgradeMissingDependency,
727 PublishUpgradeDependencyDowngrade,
728 PackageUpgradeError {
729 kind: PackageUpgradeError,
730 },
731 WrittenObjectsTooLarge {
732 object_size: u64,
733 max_object_size: u64,
734 },
735 CertificateDenied,
736 SuiMoveVerificationTimedout,
737 SharedObjectOperationNotAllowed,
738 InputObjectDeleted,
739 ExecutionCanceledDueToSharedObjectCongestion {
740 congested_objects: Vec<ObjectId>,
741 },
742
743 AddressDeniedForCoin {
744 address: Address,
745 coin_type: String,
746 },
747
748 CoinTypeGlobalPause {
749 coin_type: String,
750 },
751
752 ExecutionCanceledDueToRandomnessUnavailable,
753
754 MoveVectorElemTooBig {
755 value_size: u64,
756 max_scaled_size: u64,
757 },
758
759 MoveRawValueTooBig {
760 value_size: u64,
761 max_scaled_size: u64,
762 },
763
764 InvalidLinkage,
765 }
766
767 impl Serialize for ExecutionError {
768 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
769 where
770 S: Serializer,
771 {
772 if serializer.is_human_readable() {
773 let readable = match self.clone() {
774 Self::InsufficientGas => ReadableExecutionError::InsufficientGas,
775 Self::InvalidGasObject => ReadableExecutionError::InvalidGasObject,
776 Self::InvariantViolation => ReadableExecutionError::InvariantViolation,
777 Self::FeatureNotYetSupported => ReadableExecutionError::FeatureNotYetSupported,
778 Self::ObjectTooBig {
779 object_size,
780 max_object_size,
781 } => ReadableExecutionError::ObjectTooBig {
782 object_size,
783 max_object_size,
784 },
785 Self::PackageTooBig {
786 object_size,
787 max_object_size,
788 } => ReadableExecutionError::PackageTooBig {
789 object_size,
790 max_object_size,
791 },
792 Self::CircularObjectOwnership { object } => {
793 ReadableExecutionError::CircularObjectOwnership { object }
794 }
795 Self::InsufficientCoinBalance => {
796 ReadableExecutionError::InsufficientCoinBalance
797 }
798 Self::CoinBalanceOverflow => ReadableExecutionError::CoinBalanceOverflow,
799 Self::PublishErrorNonZeroAddress => {
800 ReadableExecutionError::PublishErrorNonZeroAddress
801 }
802 Self::SuiMoveVerificationError => {
803 ReadableExecutionError::SuiMoveVerificationError
804 }
805 Self::MovePrimitiveRuntimeError { location } => {
806 ReadableExecutionError::MovePrimitiveRuntimeError { location }
807 }
808 Self::MoveAbort { location, code } => {
809 ReadableExecutionError::MoveAbort { location, code }
810 }
811 Self::VmVerificationOrDeserializationError => {
812 ReadableExecutionError::VmVerificationOrDeserializationError
813 }
814 Self::VmInvariantViolation => ReadableExecutionError::VmInvariantViolation,
815 Self::FunctionNotFound => ReadableExecutionError::FunctionNotFound,
816 Self::ArityMismatch => ReadableExecutionError::ArityMismatch,
817 Self::TypeArityMismatch => ReadableExecutionError::TypeArityMismatch,
818 Self::NonEntryFunctionInvoked => {
819 ReadableExecutionError::NonEntryFunctionInvoked
820 }
821 Self::CommandArgumentError { argument, kind } => {
822 ReadableExecutionError::CommandArgumentError { argument, kind }
823 }
824 Self::TypeArgumentError {
825 type_argument,
826 kind,
827 } => ReadableExecutionError::TypeArgumentError {
828 type_argument,
829 kind,
830 },
831 Self::UnusedValueWithoutDrop { result, subresult } => {
832 ReadableExecutionError::UnusedValueWithoutDrop { result, subresult }
833 }
834 Self::InvalidPublicFunctionReturnType { index } => {
835 ReadableExecutionError::InvalidPublicFunctionReturnType { index }
836 }
837 Self::InvalidTransferObject => ReadableExecutionError::InvalidTransferObject,
838 Self::EffectsTooLarge {
839 current_size,
840 max_size,
841 } => ReadableExecutionError::EffectsTooLarge {
842 current_size,
843 max_size,
844 },
845 Self::PublishUpgradeMissingDependency => {
846 ReadableExecutionError::PublishUpgradeMissingDependency
847 }
848 Self::PublishUpgradeDependencyDowngrade => {
849 ReadableExecutionError::PublishUpgradeDependencyDowngrade
850 }
851 Self::PackageUpgradeError { kind } => {
852 ReadableExecutionError::PackageUpgradeError { kind }
853 }
854 Self::WrittenObjectsTooLarge {
855 object_size,
856 max_object_size,
857 } => ReadableExecutionError::WrittenObjectsTooLarge {
858 object_size,
859 max_object_size,
860 },
861 Self::CertificateDenied => ReadableExecutionError::CertificateDenied,
862 Self::SuiMoveVerificationTimedout => {
863 ReadableExecutionError::SuiMoveVerificationTimedout
864 }
865 Self::SharedObjectOperationNotAllowed => {
866 ReadableExecutionError::SharedObjectOperationNotAllowed
867 }
868 Self::InputObjectDeleted => ReadableExecutionError::InputObjectDeleted,
869 Self::ExecutionCanceledDueToSharedObjectCongestion { congested_objects } => {
870 ReadableExecutionError::ExecutionCanceledDueToSharedObjectCongestion {
871 congested_objects,
872 }
873 }
874 Self::AddressDeniedForCoin { address, coin_type } => {
875 ReadableExecutionError::AddressDeniedForCoin { address, coin_type }
876 }
877 Self::CoinTypeGlobalPause { coin_type } => {
878 ReadableExecutionError::CoinTypeGlobalPause { coin_type }
879 }
880 Self::ExecutionCanceledDueToRandomnessUnavailable => {
881 ReadableExecutionError::ExecutionCanceledDueToRandomnessUnavailable
882 }
883 Self::MoveVectorElemTooBig {
884 value_size,
885 max_scaled_size,
886 } => ReadableExecutionError::MoveVectorElemTooBig {
887 value_size,
888 max_scaled_size,
889 },
890 Self::MoveRawValueTooBig {
891 value_size,
892 max_scaled_size,
893 } => ReadableExecutionError::MoveRawValueTooBig {
894 value_size,
895 max_scaled_size,
896 },
897 Self::InvalidLinkage => ReadableExecutionError::InvalidLinkage,
898 };
899 readable.serialize(serializer)
900 } else {
901 let binary = match self.clone() {
902 Self::InsufficientGas => BinaryExecutionError::InsufficientGas,
903 Self::InvalidGasObject => BinaryExecutionError::InvalidGasObject,
904 Self::InvariantViolation => BinaryExecutionError::InvariantViolation,
905 Self::FeatureNotYetSupported => BinaryExecutionError::FeatureNotYetSupported,
906 Self::ObjectTooBig {
907 object_size,
908 max_object_size,
909 } => BinaryExecutionError::ObjectTooBig {
910 object_size,
911 max_object_size,
912 },
913 Self::PackageTooBig {
914 object_size,
915 max_object_size,
916 } => BinaryExecutionError::PackageTooBig {
917 object_size,
918 max_object_size,
919 },
920 Self::CircularObjectOwnership { object } => {
921 BinaryExecutionError::CircularObjectOwnership { object }
922 }
923 Self::InsufficientCoinBalance => BinaryExecutionError::InsufficientCoinBalance,
924 Self::CoinBalanceOverflow => BinaryExecutionError::CoinBalanceOverflow,
925 Self::PublishErrorNonZeroAddress => {
926 BinaryExecutionError::PublishErrorNonZeroAddress
927 }
928 Self::SuiMoveVerificationError => {
929 BinaryExecutionError::SuiMoveVerificationError
930 }
931 Self::MovePrimitiveRuntimeError { location } => {
932 BinaryExecutionError::MovePrimitiveRuntimeError { location }
933 }
934 Self::MoveAbort { location, code } => {
935 BinaryExecutionError::MoveAbort { location, code }
936 }
937 Self::VmVerificationOrDeserializationError => {
938 BinaryExecutionError::VmVerificationOrDeserializationError
939 }
940 Self::VmInvariantViolation => BinaryExecutionError::VmInvariantViolation,
941 Self::FunctionNotFound => BinaryExecutionError::FunctionNotFound,
942 Self::ArityMismatch => BinaryExecutionError::ArityMismatch,
943 Self::TypeArityMismatch => BinaryExecutionError::TypeArityMismatch,
944 Self::NonEntryFunctionInvoked => BinaryExecutionError::NonEntryFunctionInvoked,
945 Self::CommandArgumentError { argument, kind } => {
946 BinaryExecutionError::CommandArgumentError { argument, kind }
947 }
948 Self::TypeArgumentError {
949 type_argument,
950 kind,
951 } => BinaryExecutionError::TypeArgumentError {
952 type_argument,
953 kind,
954 },
955 Self::UnusedValueWithoutDrop { result, subresult } => {
956 BinaryExecutionError::UnusedValueWithoutDrop { result, subresult }
957 }
958 Self::InvalidPublicFunctionReturnType { index } => {
959 BinaryExecutionError::InvalidPublicFunctionReturnType { index }
960 }
961 Self::InvalidTransferObject => BinaryExecutionError::InvalidTransferObject,
962 Self::EffectsTooLarge {
963 current_size,
964 max_size,
965 } => BinaryExecutionError::EffectsTooLarge {
966 current_size,
967 max_size,
968 },
969 Self::PublishUpgradeMissingDependency => {
970 BinaryExecutionError::PublishUpgradeMissingDependency
971 }
972 Self::PublishUpgradeDependencyDowngrade => {
973 BinaryExecutionError::PublishUpgradeDependencyDowngrade
974 }
975 Self::PackageUpgradeError { kind } => {
976 BinaryExecutionError::PackageUpgradeError { kind }
977 }
978 Self::WrittenObjectsTooLarge {
979 object_size,
980 max_object_size,
981 } => BinaryExecutionError::WrittenObjectsTooLarge {
982 object_size,
983 max_object_size,
984 },
985 Self::CertificateDenied => BinaryExecutionError::CertificateDenied,
986 Self::SuiMoveVerificationTimedout => {
987 BinaryExecutionError::SuiMoveVerificationTimedout
988 }
989 Self::SharedObjectOperationNotAllowed => {
990 BinaryExecutionError::SharedObjectOperationNotAllowed
991 }
992 Self::InputObjectDeleted => BinaryExecutionError::InputObjectDeleted,
993 Self::ExecutionCanceledDueToSharedObjectCongestion { congested_objects } => {
994 BinaryExecutionError::ExecutionCanceledDueToSharedObjectCongestion {
995 congested_objects,
996 }
997 }
998 Self::AddressDeniedForCoin { address, coin_type } => {
999 BinaryExecutionError::AddressDeniedForCoin { address, coin_type }
1000 }
1001 Self::CoinTypeGlobalPause { coin_type } => {
1002 BinaryExecutionError::CoinTypeGlobalPause { coin_type }
1003 }
1004 Self::ExecutionCanceledDueToRandomnessUnavailable => {
1005 BinaryExecutionError::ExecutionCanceledDueToRandomnessUnavailable
1006 }
1007 Self::MoveVectorElemTooBig {
1008 value_size,
1009 max_scaled_size,
1010 } => BinaryExecutionError::MoveVectorElemTooBig {
1011 value_size,
1012 max_scaled_size,
1013 },
1014 Self::MoveRawValueTooBig {
1015 value_size,
1016 max_scaled_size,
1017 } => BinaryExecutionError::MoveRawValueTooBig {
1018 value_size,
1019 max_scaled_size,
1020 },
1021 Self::InvalidLinkage => BinaryExecutionError::InvalidLinkage,
1022 };
1023 binary.serialize(serializer)
1024 }
1025 }
1026 }
1027
1028 impl<'de> Deserialize<'de> for ExecutionError {
1029 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1030 where
1031 D: Deserializer<'de>,
1032 {
1033 if deserializer.is_human_readable() {
1034 ReadableExecutionError::deserialize(deserializer).map(|readable| match readable {
1035 ReadableExecutionError::InsufficientGas => Self::InsufficientGas,
1036 ReadableExecutionError::InvalidGasObject => Self::InvalidGasObject,
1037 ReadableExecutionError::InvariantViolation => Self::InvariantViolation,
1038 ReadableExecutionError::FeatureNotYetSupported => Self::FeatureNotYetSupported,
1039 ReadableExecutionError::ObjectTooBig {
1040 object_size,
1041 max_object_size,
1042 } => Self::ObjectTooBig {
1043 object_size,
1044 max_object_size,
1045 },
1046 ReadableExecutionError::PackageTooBig {
1047 object_size,
1048 max_object_size,
1049 } => Self::PackageTooBig {
1050 object_size,
1051 max_object_size,
1052 },
1053 ReadableExecutionError::CircularObjectOwnership { object } => {
1054 Self::CircularObjectOwnership { object }
1055 }
1056 ReadableExecutionError::InsufficientCoinBalance => {
1057 Self::InsufficientCoinBalance
1058 }
1059 ReadableExecutionError::CoinBalanceOverflow => Self::CoinBalanceOverflow,
1060 ReadableExecutionError::PublishErrorNonZeroAddress => {
1061 Self::PublishErrorNonZeroAddress
1062 }
1063 ReadableExecutionError::SuiMoveVerificationError => {
1064 Self::SuiMoveVerificationError
1065 }
1066 ReadableExecutionError::MovePrimitiveRuntimeError { location } => {
1067 Self::MovePrimitiveRuntimeError { location }
1068 }
1069 ReadableExecutionError::MoveAbort { location, code } => {
1070 Self::MoveAbort { location, code }
1071 }
1072 ReadableExecutionError::VmVerificationOrDeserializationError => {
1073 Self::VmVerificationOrDeserializationError
1074 }
1075 ReadableExecutionError::VmInvariantViolation => Self::VmInvariantViolation,
1076 ReadableExecutionError::FunctionNotFound => Self::FunctionNotFound,
1077 ReadableExecutionError::ArityMismatch => Self::ArityMismatch,
1078 ReadableExecutionError::TypeArityMismatch => Self::TypeArityMismatch,
1079 ReadableExecutionError::NonEntryFunctionInvoked => {
1080 Self::NonEntryFunctionInvoked
1081 }
1082 ReadableExecutionError::CommandArgumentError { argument, kind } => {
1083 Self::CommandArgumentError { argument, kind }
1084 }
1085 ReadableExecutionError::TypeArgumentError {
1086 type_argument,
1087 kind,
1088 } => Self::TypeArgumentError {
1089 type_argument,
1090 kind,
1091 },
1092 ReadableExecutionError::UnusedValueWithoutDrop { result, subresult } => {
1093 Self::UnusedValueWithoutDrop { result, subresult }
1094 }
1095 ReadableExecutionError::InvalidPublicFunctionReturnType { index } => {
1096 Self::InvalidPublicFunctionReturnType { index }
1097 }
1098 ReadableExecutionError::InvalidTransferObject => Self::InvalidTransferObject,
1099 ReadableExecutionError::EffectsTooLarge {
1100 current_size,
1101 max_size,
1102 } => Self::EffectsTooLarge {
1103 current_size,
1104 max_size,
1105 },
1106 ReadableExecutionError::PublishUpgradeMissingDependency => {
1107 Self::PublishUpgradeMissingDependency
1108 }
1109 ReadableExecutionError::PublishUpgradeDependencyDowngrade => {
1110 Self::PublishUpgradeDependencyDowngrade
1111 }
1112 ReadableExecutionError::PackageUpgradeError { kind } => {
1113 Self::PackageUpgradeError { kind }
1114 }
1115 ReadableExecutionError::WrittenObjectsTooLarge {
1116 object_size,
1117 max_object_size,
1118 } => Self::WrittenObjectsTooLarge {
1119 object_size,
1120 max_object_size,
1121 },
1122 ReadableExecutionError::CertificateDenied => Self::CertificateDenied,
1123 ReadableExecutionError::SuiMoveVerificationTimedout => {
1124 Self::SuiMoveVerificationTimedout
1125 }
1126 ReadableExecutionError::SharedObjectOperationNotAllowed => {
1127 Self::SharedObjectOperationNotAllowed
1128 }
1129 ReadableExecutionError::InputObjectDeleted => Self::InputObjectDeleted,
1130 ReadableExecutionError::ExecutionCanceledDueToSharedObjectCongestion {
1131 congested_objects,
1132 } => Self::ExecutionCanceledDueToSharedObjectCongestion { congested_objects },
1133 ReadableExecutionError::AddressDeniedForCoin { address, coin_type } => {
1134 Self::AddressDeniedForCoin { address, coin_type }
1135 }
1136 ReadableExecutionError::CoinTypeGlobalPause { coin_type } => {
1137 Self::CoinTypeGlobalPause { coin_type }
1138 }
1139 ReadableExecutionError::ExecutionCanceledDueToRandomnessUnavailable => {
1140 Self::ExecutionCanceledDueToRandomnessUnavailable
1141 }
1142 ReadableExecutionError::MoveVectorElemTooBig {
1143 value_size,
1144 max_scaled_size,
1145 } => Self::MoveVectorElemTooBig {
1146 value_size,
1147 max_scaled_size,
1148 },
1149 ReadableExecutionError::MoveRawValueTooBig {
1150 value_size,
1151 max_scaled_size,
1152 } => Self::MoveRawValueTooBig {
1153 value_size,
1154 max_scaled_size,
1155 },
1156 ReadableExecutionError::InvalidLinkage => Self::InvalidLinkage,
1157 })
1158 } else {
1159 BinaryExecutionError::deserialize(deserializer).map(|binary| match binary {
1160 BinaryExecutionError::InsufficientGas => Self::InsufficientGas,
1161 BinaryExecutionError::InvalidGasObject => Self::InvalidGasObject,
1162 BinaryExecutionError::InvariantViolation => Self::InvariantViolation,
1163 BinaryExecutionError::FeatureNotYetSupported => Self::FeatureNotYetSupported,
1164 BinaryExecutionError::ObjectTooBig {
1165 object_size,
1166 max_object_size,
1167 } => Self::ObjectTooBig {
1168 object_size,
1169 max_object_size,
1170 },
1171 BinaryExecutionError::PackageTooBig {
1172 object_size,
1173 max_object_size,
1174 } => Self::PackageTooBig {
1175 object_size,
1176 max_object_size,
1177 },
1178 BinaryExecutionError::CircularObjectOwnership { object } => {
1179 Self::CircularObjectOwnership { object }
1180 }
1181 BinaryExecutionError::InsufficientCoinBalance => Self::InsufficientCoinBalance,
1182 BinaryExecutionError::CoinBalanceOverflow => Self::CoinBalanceOverflow,
1183 BinaryExecutionError::PublishErrorNonZeroAddress => {
1184 Self::PublishErrorNonZeroAddress
1185 }
1186 BinaryExecutionError::SuiMoveVerificationError => {
1187 Self::SuiMoveVerificationError
1188 }
1189 BinaryExecutionError::MovePrimitiveRuntimeError { location } => {
1190 Self::MovePrimitiveRuntimeError { location }
1191 }
1192 BinaryExecutionError::MoveAbort { location, code } => {
1193 Self::MoveAbort { location, code }
1194 }
1195 BinaryExecutionError::VmVerificationOrDeserializationError => {
1196 Self::VmVerificationOrDeserializationError
1197 }
1198 BinaryExecutionError::VmInvariantViolation => Self::VmInvariantViolation,
1199 BinaryExecutionError::FunctionNotFound => Self::FunctionNotFound,
1200 BinaryExecutionError::ArityMismatch => Self::ArityMismatch,
1201 BinaryExecutionError::TypeArityMismatch => Self::TypeArityMismatch,
1202 BinaryExecutionError::NonEntryFunctionInvoked => Self::NonEntryFunctionInvoked,
1203 BinaryExecutionError::CommandArgumentError { argument, kind } => {
1204 Self::CommandArgumentError { argument, kind }
1205 }
1206 BinaryExecutionError::TypeArgumentError {
1207 type_argument,
1208 kind,
1209 } => Self::TypeArgumentError {
1210 type_argument,
1211 kind,
1212 },
1213 BinaryExecutionError::UnusedValueWithoutDrop { result, subresult } => {
1214 Self::UnusedValueWithoutDrop { result, subresult }
1215 }
1216 BinaryExecutionError::InvalidPublicFunctionReturnType { index } => {
1217 Self::InvalidPublicFunctionReturnType { index }
1218 }
1219 BinaryExecutionError::InvalidTransferObject => Self::InvalidTransferObject,
1220 BinaryExecutionError::EffectsTooLarge {
1221 current_size,
1222 max_size,
1223 } => Self::EffectsTooLarge {
1224 current_size,
1225 max_size,
1226 },
1227 BinaryExecutionError::PublishUpgradeMissingDependency => {
1228 Self::PublishUpgradeMissingDependency
1229 }
1230 BinaryExecutionError::PublishUpgradeDependencyDowngrade => {
1231 Self::PublishUpgradeDependencyDowngrade
1232 }
1233 BinaryExecutionError::PackageUpgradeError { kind } => {
1234 Self::PackageUpgradeError { kind }
1235 }
1236 BinaryExecutionError::WrittenObjectsTooLarge {
1237 object_size,
1238 max_object_size,
1239 } => Self::WrittenObjectsTooLarge {
1240 object_size,
1241 max_object_size,
1242 },
1243 BinaryExecutionError::CertificateDenied => Self::CertificateDenied,
1244 BinaryExecutionError::SuiMoveVerificationTimedout => {
1245 Self::SuiMoveVerificationTimedout
1246 }
1247 BinaryExecutionError::SharedObjectOperationNotAllowed => {
1248 Self::SharedObjectOperationNotAllowed
1249 }
1250 BinaryExecutionError::InputObjectDeleted => Self::InputObjectDeleted,
1251 BinaryExecutionError::ExecutionCanceledDueToSharedObjectCongestion {
1252 congested_objects,
1253 } => Self::ExecutionCanceledDueToSharedObjectCongestion { congested_objects },
1254 BinaryExecutionError::AddressDeniedForCoin { address, coin_type } => {
1255 Self::AddressDeniedForCoin { address, coin_type }
1256 }
1257 BinaryExecutionError::CoinTypeGlobalPause { coin_type } => {
1258 Self::CoinTypeGlobalPause { coin_type }
1259 }
1260 BinaryExecutionError::ExecutionCanceledDueToRandomnessUnavailable => {
1261 Self::ExecutionCanceledDueToRandomnessUnavailable
1262 }
1263 BinaryExecutionError::MoveVectorElemTooBig {
1264 value_size,
1265 max_scaled_size,
1266 } => Self::MoveVectorElemTooBig {
1267 value_size,
1268 max_scaled_size,
1269 },
1270 BinaryExecutionError::MoveRawValueTooBig {
1271 value_size,
1272 max_scaled_size,
1273 } => Self::MoveRawValueTooBig {
1274 value_size,
1275 max_scaled_size,
1276 },
1277 BinaryExecutionError::InvalidLinkage => Self::InvalidLinkage,
1278 })
1279 }
1280 }
1281 }
1282
1283 #[derive(serde_derive::Serialize, serde_derive::Deserialize)]
1284 #[serde(tag = "kind", rename_all = "snake_case")]
1285 enum ReadableCommandArgumentError {
1286 TypeMismatch,
1287 InvalidBcsBytes,
1288 InvalidUsageOfPureArgument,
1289 InvalidArgumentToPrivateEntryFunction,
1290 IndexOutOfBounds { index: u16 },
1291 SecondaryIndexOutOfBounds { result: u16, subresult: u16 },
1292 InvalidResultArity { result: u16 },
1293 InvalidGasCoinUsage,
1294 InvalidValueUsage,
1295 InvalidObjectByValue,
1296 InvalidObjectByMutRef,
1297 SharedObjectOperationNotAllowed,
1298 InvalidArgumentArity,
1299 }
1300
1301 #[derive(serde_derive::Serialize, serde_derive::Deserialize)]
1302 enum BinaryCommandArgumentError {
1303 TypeMismatch,
1304 InvalidBcsBytes,
1305 InvalidUsageOfPureArgument,
1306 InvalidArgumentToPrivateEntryFunction,
1307 IndexOutOfBounds { index: u16 },
1308 SecondaryIndexOutOfBounds { result: u16, subresult: u16 },
1309 InvalidResultArity { result: u16 },
1310 InvalidGasCoinUsage,
1311 InvalidValueUsage,
1312 InvalidObjectByValue,
1313 InvalidObjectByMutRef,
1314 SharedObjectOperationNotAllowed,
1315 InvalidArgumentArity,
1316 }
1317
1318 impl Serialize for CommandArgumentError {
1319 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1320 where
1321 S: Serializer,
1322 {
1323 if serializer.is_human_readable() {
1324 let readable = match self.clone() {
1325 Self::TypeMismatch => ReadableCommandArgumentError::TypeMismatch,
1326 Self::InvalidBcsBytes => ReadableCommandArgumentError::InvalidBcsBytes,
1327 Self::InvalidUsageOfPureArgument => {
1328 ReadableCommandArgumentError::InvalidUsageOfPureArgument
1329 }
1330 Self::InvalidArgumentToPrivateEntryFunction => {
1331 ReadableCommandArgumentError::InvalidArgumentToPrivateEntryFunction
1332 }
1333 Self::IndexOutOfBounds { index } => {
1334 ReadableCommandArgumentError::IndexOutOfBounds { index }
1335 }
1336 Self::SecondaryIndexOutOfBounds { result, subresult } => {
1337 ReadableCommandArgumentError::SecondaryIndexOutOfBounds {
1338 result,
1339 subresult,
1340 }
1341 }
1342 Self::InvalidResultArity { result } => {
1343 ReadableCommandArgumentError::InvalidResultArity { result }
1344 }
1345 Self::InvalidGasCoinUsage => ReadableCommandArgumentError::InvalidGasCoinUsage,
1346 Self::InvalidValueUsage => ReadableCommandArgumentError::InvalidValueUsage,
1347 Self::InvalidObjectByValue => {
1348 ReadableCommandArgumentError::InvalidObjectByValue
1349 }
1350 Self::InvalidObjectByMutRef => {
1351 ReadableCommandArgumentError::InvalidObjectByMutRef
1352 }
1353 Self::SharedObjectOperationNotAllowed => {
1354 ReadableCommandArgumentError::SharedObjectOperationNotAllowed
1355 }
1356 Self::InvalidArgumentArity => {
1357 ReadableCommandArgumentError::InvalidArgumentArity
1358 }
1359 };
1360 readable.serialize(serializer)
1361 } else {
1362 let binary = match self.clone() {
1363 Self::TypeMismatch => BinaryCommandArgumentError::TypeMismatch,
1364 Self::InvalidBcsBytes => BinaryCommandArgumentError::InvalidBcsBytes,
1365 Self::InvalidUsageOfPureArgument => {
1366 BinaryCommandArgumentError::InvalidUsageOfPureArgument
1367 }
1368 Self::InvalidArgumentToPrivateEntryFunction => {
1369 BinaryCommandArgumentError::InvalidArgumentToPrivateEntryFunction
1370 }
1371 Self::IndexOutOfBounds { index } => {
1372 BinaryCommandArgumentError::IndexOutOfBounds { index }
1373 }
1374 Self::SecondaryIndexOutOfBounds { result, subresult } => {
1375 BinaryCommandArgumentError::SecondaryIndexOutOfBounds { result, subresult }
1376 }
1377 Self::InvalidResultArity { result } => {
1378 BinaryCommandArgumentError::InvalidResultArity { result }
1379 }
1380 Self::InvalidGasCoinUsage => BinaryCommandArgumentError::InvalidGasCoinUsage,
1381 Self::InvalidValueUsage => BinaryCommandArgumentError::InvalidValueUsage,
1382 Self::InvalidObjectByValue => BinaryCommandArgumentError::InvalidObjectByValue,
1383 Self::InvalidObjectByMutRef => {
1384 BinaryCommandArgumentError::InvalidObjectByMutRef
1385 }
1386 Self::SharedObjectOperationNotAllowed => {
1387 BinaryCommandArgumentError::SharedObjectOperationNotAllowed
1388 }
1389 Self::InvalidArgumentArity => BinaryCommandArgumentError::InvalidArgumentArity,
1390 };
1391 binary.serialize(serializer)
1392 }
1393 }
1394 }
1395
1396 impl<'de> Deserialize<'de> for CommandArgumentError {
1397 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1398 where
1399 D: Deserializer<'de>,
1400 {
1401 if deserializer.is_human_readable() {
1402 ReadableCommandArgumentError::deserialize(deserializer).map(|readable| {
1403 match readable {
1404 ReadableCommandArgumentError::TypeMismatch => Self::TypeMismatch,
1405 ReadableCommandArgumentError::InvalidBcsBytes => Self::InvalidBcsBytes,
1406 ReadableCommandArgumentError::InvalidUsageOfPureArgument => {
1407 Self::InvalidUsageOfPureArgument
1408 }
1409 ReadableCommandArgumentError::InvalidArgumentToPrivateEntryFunction => {
1410 Self::InvalidArgumentToPrivateEntryFunction
1411 }
1412 ReadableCommandArgumentError::IndexOutOfBounds { index } => {
1413 Self::IndexOutOfBounds { index }
1414 }
1415 ReadableCommandArgumentError::SecondaryIndexOutOfBounds {
1416 result,
1417 subresult,
1418 } => Self::SecondaryIndexOutOfBounds { result, subresult },
1419 ReadableCommandArgumentError::InvalidResultArity { result } => {
1420 Self::InvalidResultArity { result }
1421 }
1422 ReadableCommandArgumentError::InvalidGasCoinUsage => {
1423 Self::InvalidGasCoinUsage
1424 }
1425 ReadableCommandArgumentError::InvalidValueUsage => Self::InvalidValueUsage,
1426 ReadableCommandArgumentError::InvalidObjectByValue => {
1427 Self::InvalidObjectByValue
1428 }
1429 ReadableCommandArgumentError::InvalidObjectByMutRef => {
1430 Self::InvalidObjectByMutRef
1431 }
1432 ReadableCommandArgumentError::SharedObjectOperationNotAllowed => {
1433 Self::SharedObjectOperationNotAllowed
1434 }
1435 ReadableCommandArgumentError::InvalidArgumentArity => {
1436 Self::InvalidArgumentArity
1437 }
1438 }
1439 })
1440 } else {
1441 BinaryCommandArgumentError::deserialize(deserializer).map(|binary| match binary {
1442 BinaryCommandArgumentError::TypeMismatch => Self::TypeMismatch,
1443 BinaryCommandArgumentError::InvalidBcsBytes => Self::InvalidBcsBytes,
1444 BinaryCommandArgumentError::InvalidUsageOfPureArgument => {
1445 Self::InvalidUsageOfPureArgument
1446 }
1447 BinaryCommandArgumentError::InvalidArgumentToPrivateEntryFunction => {
1448 Self::InvalidArgumentToPrivateEntryFunction
1449 }
1450 BinaryCommandArgumentError::IndexOutOfBounds { index } => {
1451 Self::IndexOutOfBounds { index }
1452 }
1453 BinaryCommandArgumentError::SecondaryIndexOutOfBounds { result, subresult } => {
1454 Self::SecondaryIndexOutOfBounds { result, subresult }
1455 }
1456 BinaryCommandArgumentError::InvalidResultArity { result } => {
1457 Self::InvalidResultArity { result }
1458 }
1459 BinaryCommandArgumentError::InvalidGasCoinUsage => Self::InvalidGasCoinUsage,
1460 BinaryCommandArgumentError::InvalidValueUsage => Self::InvalidValueUsage,
1461 BinaryCommandArgumentError::InvalidObjectByValue => Self::InvalidObjectByValue,
1462 BinaryCommandArgumentError::InvalidObjectByMutRef => {
1463 Self::InvalidObjectByMutRef
1464 }
1465 BinaryCommandArgumentError::SharedObjectOperationNotAllowed => {
1466 Self::SharedObjectOperationNotAllowed
1467 }
1468 BinaryCommandArgumentError::InvalidArgumentArity => Self::InvalidArgumentArity,
1469 })
1470 }
1471 }
1472 }
1473
1474 #[derive(serde_derive::Serialize, serde_derive::Deserialize)]
1475 #[serde(tag = "kind", rename_all = "snake_case")]
1476 enum ReadablePackageUpgradeError {
1477 UnableToFetchPackage {
1478 package_id: ObjectId,
1479 },
1480 NotAPackage {
1481 object_id: ObjectId,
1482 },
1483 IncompatibleUpgrade,
1484 DigestDoesNotMatch {
1485 digest: Digest,
1486 },
1487 UnknownUpgradePolicy {
1488 policy: u8,
1489 },
1490 PackageIdDoesNotMatch {
1491 package_id: ObjectId,
1492 ticket_id: ObjectId,
1493 },
1494 }
1495
1496 #[derive(serde_derive::Serialize, serde_derive::Deserialize)]
1497 enum BinaryPackageUpgradeError {
1498 UnableToFetchPackage {
1499 package_id: ObjectId,
1500 },
1501 NotAPackage {
1502 object_id: ObjectId,
1503 },
1504 IncompatibleUpgrade,
1505 DigestDoesNotMatch {
1506 digest: Digest,
1507 },
1508 UnknownUpgradePolicy {
1509 policy: u8,
1510 },
1511 PackageIdDoesNotMatch {
1512 package_id: ObjectId,
1513 ticket_id: ObjectId,
1514 },
1515 }
1516
1517 impl Serialize for PackageUpgradeError {
1518 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1519 where
1520 S: Serializer,
1521 {
1522 if serializer.is_human_readable() {
1523 let readable = match self.clone() {
1524 Self::UnableToFetchPackage { package_id } => {
1525 ReadablePackageUpgradeError::UnableToFetchPackage { package_id }
1526 }
1527 Self::NotAPackage { object_id } => {
1528 ReadablePackageUpgradeError::NotAPackage { object_id }
1529 }
1530 Self::IncompatibleUpgrade => ReadablePackageUpgradeError::IncompatibleUpgrade,
1531 Self::DigestDoesNotMatch { digest } => {
1532 ReadablePackageUpgradeError::DigestDoesNotMatch { digest }
1533 }
1534 Self::UnknownUpgradePolicy { policy } => {
1535 ReadablePackageUpgradeError::UnknownUpgradePolicy { policy }
1536 }
1537 Self::PackageIdDoesNotMatch {
1538 package_id,
1539 ticket_id,
1540 } => ReadablePackageUpgradeError::PackageIdDoesNotMatch {
1541 package_id,
1542 ticket_id,
1543 },
1544 };
1545 readable.serialize(serializer)
1546 } else {
1547 let binary = match self.clone() {
1548 Self::UnableToFetchPackage { package_id } => {
1549 BinaryPackageUpgradeError::UnableToFetchPackage { package_id }
1550 }
1551 Self::NotAPackage { object_id } => {
1552 BinaryPackageUpgradeError::NotAPackage { object_id }
1553 }
1554 Self::IncompatibleUpgrade => BinaryPackageUpgradeError::IncompatibleUpgrade,
1555 Self::DigestDoesNotMatch { digest } => {
1556 BinaryPackageUpgradeError::DigestDoesNotMatch { digest }
1557 }
1558 Self::UnknownUpgradePolicy { policy } => {
1559 BinaryPackageUpgradeError::UnknownUpgradePolicy { policy }
1560 }
1561 Self::PackageIdDoesNotMatch {
1562 package_id,
1563 ticket_id,
1564 } => BinaryPackageUpgradeError::PackageIdDoesNotMatch {
1565 package_id,
1566 ticket_id,
1567 },
1568 };
1569 binary.serialize(serializer)
1570 }
1571 }
1572 }
1573
1574 impl<'de> Deserialize<'de> for PackageUpgradeError {
1575 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1576 where
1577 D: Deserializer<'de>,
1578 {
1579 if deserializer.is_human_readable() {
1580 ReadablePackageUpgradeError::deserialize(deserializer).map(
1581 |readable| match readable {
1582 ReadablePackageUpgradeError::UnableToFetchPackage { package_id } => {
1583 Self::UnableToFetchPackage { package_id }
1584 }
1585 ReadablePackageUpgradeError::NotAPackage { object_id } => {
1586 Self::NotAPackage { object_id }
1587 }
1588 ReadablePackageUpgradeError::IncompatibleUpgrade => {
1589 Self::IncompatibleUpgrade
1590 }
1591 ReadablePackageUpgradeError::DigestDoesNotMatch { digest } => {
1592 Self::DigestDoesNotMatch { digest }
1593 }
1594 ReadablePackageUpgradeError::UnknownUpgradePolicy { policy } => {
1595 Self::UnknownUpgradePolicy { policy }
1596 }
1597 ReadablePackageUpgradeError::PackageIdDoesNotMatch {
1598 package_id,
1599 ticket_id,
1600 } => Self::PackageIdDoesNotMatch {
1601 package_id,
1602 ticket_id,
1603 },
1604 },
1605 )
1606 } else {
1607 BinaryPackageUpgradeError::deserialize(deserializer).map(|binary| match binary {
1608 BinaryPackageUpgradeError::UnableToFetchPackage { package_id } => {
1609 Self::UnableToFetchPackage { package_id }
1610 }
1611 BinaryPackageUpgradeError::NotAPackage { object_id } => {
1612 Self::NotAPackage { object_id }
1613 }
1614 BinaryPackageUpgradeError::IncompatibleUpgrade => Self::IncompatibleUpgrade,
1615 BinaryPackageUpgradeError::DigestDoesNotMatch { digest } => {
1616 Self::DigestDoesNotMatch { digest }
1617 }
1618 BinaryPackageUpgradeError::UnknownUpgradePolicy { policy } => {
1619 Self::UnknownUpgradePolicy { policy }
1620 }
1621 BinaryPackageUpgradeError::PackageIdDoesNotMatch {
1622 package_id,
1623 ticket_id,
1624 } => Self::PackageIdDoesNotMatch {
1625 package_id,
1626 ticket_id,
1627 },
1628 })
1629 }
1630 }
1631 }
1632}