Skip to main content

AsChunk

Trait AsChunk 

Source
pub trait AsChunk<'lua> {
    // Required method
    fn source(&self) -> IoResult<Cow<'_, [u8]>>;

    // Provided methods
    fn name(&self) -> Option<StdString> { ... }
    fn env(&self, _lua: &'lua Lua) -> Result<Option<Value<'lua>>> { ... }
    fn mode(&self) -> Option<ChunkMode> { ... }
}
Expand description

Trait for types loadable by Lua and convertible to a Chunk

Required Methods§

Source

fn source(&self) -> IoResult<Cow<'_, [u8]>>

Returns chunk data (can be text or binary)

Provided Methods§

Source

fn name(&self) -> Option<StdString>

Returns optional chunk name

Source

fn env(&self, _lua: &'lua Lua) -> Result<Option<Value<'lua>>>

Returns optional chunk environment

Source

fn mode(&self) -> Option<ChunkMode>

Returns optional chunk mode (text or binary)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'lua> AsChunk<'lua> for str

Source§

fn source(&self) -> IoResult<Cow<'_, [u8]>>

Source§

impl<'lua> AsChunk<'lua> for String

Source§

fn source(&self) -> IoResult<Cow<'_, [u8]>>

Source§

impl<'lua> AsChunk<'lua> for Vec<u8>

Source§

fn source(&self) -> IoResult<Cow<'_, [u8]>>

Source§

impl<'lua> AsChunk<'lua> for Path

Source§

fn source(&self) -> IoResult<Cow<'_, [u8]>>

Source§

fn name(&self) -> Option<StdString>

Source§

impl<'lua> AsChunk<'lua> for PathBuf

Source§

fn source(&self) -> IoResult<Cow<'_, [u8]>>

Source§

fn name(&self) -> Option<StdString>

Source§

impl<'lua> AsChunk<'lua> for [u8]

Source§

fn source(&self) -> IoResult<Cow<'_, [u8]>>

Implementors§