return RPC_PORT_ERROR_NONE;
}
+
+RPC_API int rpc_port_parcel_reset_reader(rpc_port_parcel_h h) {
+ if (h == nullptr)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ Parcel* p = static_cast<Parcel*>(h);
+
+ p->ResetReader();
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+RPC_API int rpc_port_parcel_to_array(rpc_port_parcel_h h, void **array,
+ unsigned int *size) {
+ if (h == nullptr || !array || !size)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ Parcel* p = static_cast<Parcel*>(h);
+
+ const auto& ptr = p->GetRaw();
+ void* array_ptr = malloc(ptr.size());
+ if (!array_ptr)
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+
+ memcpy(array_ptr, ptr.data(), ptr.size());
+ *array = array_ptr;
+ *size = ptr.size();
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+RPC_API int rpc_port_parcel_from_array(rpc_port_parcel_h h, const void *array,
+ unsigned int size) {
+ if (h == nullptr || !array || size == 0)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ Parcel* p = static_cast<Parcel*>(h);
+
+ p->Reset(reinterpret_cast<const unsigned char*>(array), size);
+
+ return RPC_PORT_ERROR_NONE;
+}
\ No newline at end of file