Skip to content

Commit

Permalink
ManagedVecItem - lo longer implemented for handles directly
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Nov 28, 2024
1 parent d173698 commit 31c3a9a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 27 deletions.
7 changes: 2 additions & 5 deletions framework/base/src/api/managed_types/handles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ pub trait HandleTypeInfo {

use crate::codec::TryStaticCast;

use crate::{
api::{ErrorApi, ErrorApiImpl},
types::ManagedVecItem,
};
use crate::api::{ErrorApi, ErrorApiImpl};

pub type RawHandle = i32;

pub trait HandleConstraints:
ManagedVecItem + TryStaticCast + Debug + Clone + From<RawHandle> + PartialEq + PartialEq<RawHandle>
TryStaticCast + Debug + Clone + From<RawHandle> + PartialEq + PartialEq<RawHandle>
{
fn new(handle: RawHandle) -> Self;
fn to_be_bytes(&self) -> [u8; 4];
Expand Down
23 changes: 1 addition & 22 deletions framework/scenario/src/api/impl_vh/debug_handle_vh.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use multiversx_chain_vm::tx_mock::{TxContext, TxContextStack};
use multiversx_sc::{
api::{use_raw_handle, HandleConstraints, RawHandle},
api::{HandleConstraints, RawHandle},
codec::TryStaticCast,
types::ManagedVecItem,
};
use std::sync::Arc;

Expand Down Expand Up @@ -76,24 +75,4 @@ impl From<i32> for DebugHandle {
}
}

impl ManagedVecItem for DebugHandle {
type PAYLOAD = <RawHandle as ManagedVecItem>::PAYLOAD;

const SKIPS_RESERIALIZATION: bool = <RawHandle as ManagedVecItem>::SKIPS_RESERIALIZATION;

type Ref<'a> = Self;

fn read_from_payload(payload: &Self::PAYLOAD) -> Self {
use_raw_handle(RawHandle::read_from_payload(payload))
}

unsafe fn borrow_from_payload<'a>(payload: &Self::PAYLOAD) -> Self::Ref<'a> {
Self::read_from_payload(payload)
}

fn save_to_payload(self, payload: &mut Self::PAYLOAD) {
self.get_raw_handle().save_to_payload(payload);
}
}

impl TryStaticCast for DebugHandle {}

0 comments on commit 31c3a9a

Please sign in to comment.