pub struct CurrentPlugin { /* private fields */ }Expand description
CurrentPlugin stores data that is available to the caller in PDK functions, this should only be accessed from inside a host function
Implementations§
Source§impl CurrentPlugin
impl CurrentPlugin
Sourcepub fn memory_handle(&mut self, offs: u64) -> Option<MemoryHandle>
pub fn memory_handle(&mut self, offs: u64) -> Option<MemoryHandle>
Get a MemoryHandle from a memory offset
Sourcepub fn memory_str_mut(
&mut self,
handle: MemoryHandle,
) -> Result<&mut str, Error>
pub fn memory_str_mut( &mut self, handle: MemoryHandle, ) -> Result<&mut str, Error>
Access memory bytes as str
pub fn memory_str(&mut self, handle: MemoryHandle) -> Result<&str, Error>
Sourcepub fn memory_new<'a, T: ToBytes<'a>>(
&mut self,
t: T,
) -> Result<MemoryHandle, Error>
pub fn memory_new<'a, T: ToBytes<'a>>( &mut self, t: T, ) -> Result<MemoryHandle, Error>
Allocate a handle large enough for the encoded Rust type and copy it into Extism memory
Sourcepub fn memory_get<'a, T: FromBytes<'a>>(
&'a mut self,
handle: MemoryHandle,
) -> Result<T, Error>
pub fn memory_get<'a, T: FromBytes<'a>>( &'a mut self, handle: MemoryHandle, ) -> Result<T, Error>
Decode a Rust type from Extism memory
Sourcepub fn memory_get_val<'a, T: FromBytes<'a>>(
&'a mut self,
offs: &Val,
) -> Result<T, Error>
pub fn memory_get_val<'a, T: FromBytes<'a>>( &'a mut self, offs: &Val, ) -> Result<T, Error>
Decode a Rust type from Extism memory from an offset in memory specified by a Val
Sourcepub fn memory_set_val<'a, T: ToBytes<'a>>(
&'a mut self,
offs: &mut Val,
data: T,
) -> Result<(), Error>
pub fn memory_set_val<'a, T: ToBytes<'a>>( &'a mut self, offs: &mut Val, data: T, ) -> Result<(), Error>
Encode a Rust type into Extism memory and store it in the given Val, this can be used to return
values from host functions.
pub fn memory_bytes_mut( &mut self, handle: MemoryHandle, ) -> Result<&mut [u8], Error>
pub fn memory_bytes(&mut self, handle: MemoryHandle) -> Result<&[u8], Error>
pub fn host_context<T: 'static>(&mut self) -> Result<&mut T, Error>
pub fn memory_alloc(&mut self, n: u64) -> Result<MemoryHandle, Error>
Sourcepub fn memory_free(&mut self, handle: MemoryHandle) -> Result<(), Error>
pub fn memory_free(&mut self, handle: MemoryHandle) -> Result<(), Error>
Free a block of Extism plugin memory
pub fn memory_length(&mut self, offs: u64) -> Result<u64, Error>
pub fn memory_length_unsafe(&mut self, offs: u64) -> Result<u64, Error>
Sourcepub fn vars_mut(&mut self) -> &mut BTreeMap<String, Vec<u8>>
pub fn vars_mut(&mut self) -> &mut BTreeMap<String, Vec<u8>>
Mutable access to a plugin’s variables
Sourcepub fn memory_from_val(&mut self, offs: &Val) -> Option<MemoryHandle>
pub fn memory_from_val(&mut self, offs: &Val) -> Option<MemoryHandle>
Get a MemoryHandle from a Val reference - this can be used to convert a host function’s
argument directly to MemoryHandle
Sourcepub fn memory_to_val(&mut self, handle: MemoryHandle) -> Val
pub fn memory_to_val(&mut self, handle: MemoryHandle) -> Val
Get a MemoryHandle from a Val reference - this can be used to convert a host function’s
argument directly to MemoryHandle
Sourcepub fn clear_error(&mut self)
pub fn clear_error(&mut self)
Clear the current plugin error
Sourcepub fn time_remaining(&self) -> Option<Duration>
pub fn time_remaining(&self) -> Option<Duration>
Returns the remaining time before a plugin will timeout, or
None if no timeout is configured in the manifest
Trait Implementations§
impl Send for CurrentPlugin
Auto Trait Implementations§
impl Freeze for CurrentPlugin
impl !RefUnwindSafe for CurrentPlugin
impl !Sync for CurrentPlugin
impl Unpin for CurrentPlugin
impl !UnwindSafe for CurrentPlugin
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
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more