Struct ckb_std::dynamic_loading::CKBDLContext
source · #[repr(C, align(4096))]pub struct CKBDLContext<T>(/* private fields */);
Available on crate feature
ckb-types
only.Expand description
Dynamic loading context T represent a buffer type, for example: [u8; 64 * 1024], the size of T must aligned with PAGE_SIZE 4096.
Implementations§
source§impl<T> CKBDLContext<T>
impl<T> CKBDLContext<T>
sourcepub unsafe fn new() -> Self
👎Deprecated since 0.7.3: Please use the dynamic_loading_c_impl instead
pub unsafe fn new() -> Self
§Unsafe
Undefined behavior will happen if the type T is not a [u8; length]
Create instance of dynamic loading context
sourcepub fn load<'a>(
&'a mut self,
dep_cell_data_hash: &[u8]
) -> Result<Library, Error>
👎Deprecated since 0.7.3: Please use the dynamic_loading_c_impl instead
pub fn load<'a>( &'a mut self, dep_cell_data_hash: &[u8] ) -> Result<Library, Error>
Load a shared library from dep cells See module level documentation for details
sourcepub fn load_with_offset<'a>(
&'a mut self,
dep_cell_data_hash: &[u8],
offset: usize,
size: usize
) -> Result<Library, Error>
👎Deprecated since 0.7.3: Please use the dynamic_loading_c_impl instead
pub fn load_with_offset<'a>( &'a mut self, dep_cell_data_hash: &[u8], offset: usize, size: usize ) -> Result<Library, Error>
Load a shared library from dep cells to specified buffer offset. See module level documentation for details
This function is used for loading multiple libraries.
§Example
let mut context = CKBDLContext::<[u8; 64 * 1024]>::new();
let mut size = size_of_val(&context);
let mut offset = 0;
let lib1 = context.load(&CODE_HASH_LIB_1).expect("load shared lib");
size -= lib1.consumed_size()
offset += lib1.consumed_size()
let lib2 = context.load_with_offset(&CODE_HASH_LIB_2, offset, size).expect("load shared lib");
size -= lib2.consumed_size()
offset += lib2.consumed_size()
let lib3 = context.load_with_offset(&CODE_HASH_LIB_3, offset, size).expect("load shared lib");
Auto Trait Implementations§
impl<T> Freeze for CKBDLContext<T>where
T: Freeze,
impl<T> RefUnwindSafe for CKBDLContext<T>where
T: RefUnwindSafe,
impl<T> Send for CKBDLContext<T>where
T: Send,
impl<T> Sync for CKBDLContext<T>where
T: Sync,
impl<T> Unpin for CKBDLContext<T>where
T: Unpin,
impl<T> UnwindSafe for CKBDLContext<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more