sui_rpc/proto/sui/rpc/v2beta2/mod.rs
1#![allow(clippy::uninlined_format_args)]
2
3// Include the generated proto definitions
4include!("../../../generated/sui.rpc.v2beta2.rs");
5
6// Include generated field info impls
7include!("../../../generated/sui.rpc.v2beta2.field_info.rs");
8
9// Include generated serde impls
10include!("../../../generated/sui.rpc.v2beta2.serde.rs");
11// include!("../../../generated/sui.rpc.v2beta2.getters.rs");
12include!("../../../generated/sui.rpc.v2beta2.accessors.rs");
13
14pub use descriptor::FILE_DESCRIPTOR_SET;
15mod descriptor {
16 /// Byte encoded FILE_DESCRIPTOR_SET.
17 pub const FILE_DESCRIPTOR_SET: &[u8] =
18 include_bytes!("../../../generated/sui.rpc.v2beta2.fds.bin");
19
20 #[cfg(test)]
21 mod tests {
22 use super::FILE_DESCRIPTOR_SET;
23 use prost::Message as _;
24
25 #[test]
26 fn file_descriptor_set_is_valid() {
27 prost_types::FileDescriptorSet::decode(FILE_DESCRIPTOR_SET).unwrap();
28 }
29 }
30}
31
32#[cfg(test)]
33mod proptests;
34
35mod balance_change;
36mod checkpoint;
37mod effects;
38mod epoch;
39mod events;
40mod executed_transaction;
41mod execution_status;
42mod ledger_service;
43mod move_package_service;
44mod name_service;
45mod object;
46mod signatures;
47mod transaction;
48mod transaction_execution_service;
49
50//
51// Bcs
52//
53
54impl Bcs {
55 pub fn serialize<T: serde::Serialize>(value: &T) -> Result<Self, bcs::Error> {
56 bcs::to_bytes(value).map(|bcs| Self {
57 name: None,
58 value: Some(bcs.into()),
59 })
60 }
61
62 pub fn deserialize<'de, T: serde::Deserialize<'de>>(&'de self) -> Result<T, bcs::Error> {
63 bcs::from_bytes(self.value.as_deref().unwrap_or(&[]))
64 }
65}
66
67impl From<Vec<u8>> for Bcs {
68 fn from(value: Vec<u8>) -> Self {
69 Self {
70 name: None,
71 value: Some(value.into()),
72 }
73 }
74}
75
76impl From<&Bcs> for Vec<u8> {
77 fn from(value: &Bcs) -> Self {
78 value
79 .value
80 .as_ref()
81 .map(|bytes| bytes.to_vec())
82 .unwrap_or_default()
83 }
84}
85
86impl From<Bcs> for Vec<u8> {
87 fn from(value: Bcs) -> Self {
88 value
89 .value
90 .as_ref()
91 .map(|bytes| bytes.to_vec())
92 .unwrap_or_default()
93 }
94}
95
96impl From<prost::bytes::Bytes> for Bcs {
97 fn from(value: prost::bytes::Bytes) -> Self {
98 Self {
99 name: None,
100 value: Some(value),
101 }
102 }
103}
104
105impl From<&Bcs> for prost::bytes::Bytes {
106 fn from(value: &Bcs) -> Self {
107 value.value.clone().unwrap_or_default()
108 }
109}
110
111impl From<Bcs> for prost::bytes::Bytes {
112 fn from(value: Bcs) -> Self {
113 value.value.unwrap_or_default()
114 }
115}
116
117impl AsRef<str> for ErrorReason {
118 fn as_ref(&self) -> &str {
119 self.as_str_name()
120 }
121}
122
123impl From<ErrorReason> for String {
124 fn from(value: ErrorReason) -> Self {
125 value.as_ref().into()
126 }
127}