pub struct Perl { /* private fields */ }Expand description
A live Perl interpreter. Allocated by perl_alloc and torn down by
perl_destruct on drop.
The my_perl field is NonNull<PerlInterpreter> so that the
“interpreter is never null” invariant is encoded in the type.
FFI calls extract a raw pointer via Perl::as_ptr — that’s the
boundary where Rust’s safe-typed world meets the C ABI.
Implementations§
Source§impl Perl
impl Perl
Sourcepub fn new() -> Self
pub fn new() -> Self
Allocate and construct a fresh interpreter. Panics on allocation failure (typically OOM, very rare).
Sourcepub fn as_ptr(&self) -> *mut PerlInterpreter
pub fn as_ptr(&self) -> *mut PerlInterpreter
Raw pointer for FFI. The conventional name is my_perl at the
call site — see docs/plan/README.md §3.8 for naming rules.
Sourcepub unsafe fn from_raw_unchecked(p: *mut PerlInterpreter) -> Self
pub unsafe fn from_raw_unchecked(p: *mut PerlInterpreter) -> Self
Wrap a raw *mut PerlInterpreter as a borrowed Perl.
§Safety
pmust point to a live, valid interpreter.- The returned
PerlMUST NOT be dropped: itsDroprunsperl_destruct, tearing down an interpreter this constructor does not own. The intended usage is to wrap incore::mem::ManuallyDropimmediately. The#[xs_sub]proc-macro does this when a body declares amy_perl: &Perlfirst parameter.
Sourcepub fn parse<S: AsRef<str>>(&mut self, args: &[S], envp: &[S]) -> i32
pub fn parse<S: AsRef<str>>(&mut self, args: &[S], envp: &[S]) -> i32
perl_parse with an explicit args / envp slice.
Sourcepub fn parse_env_args(&mut self, args: Args, envp: Vars) -> i32
pub fn parse_env_args(&mut self, args: Args, envp: Vars) -> i32
perl_parse driven from std::env::args() / vars().
Trait Implementations§
Auto Trait Implementations§
impl !Send for Perl
impl !Sync for Perl
impl Freeze for Perl
impl RefUnwindSafe for Perl
impl Unpin for Perl
impl UnsafeUnpin for Perl
impl UnwindSafe for Perl
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