Skip to main content

AsChunk

Trait AsChunk 

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

    // Provided methods
    fn name(&self) -> Option<String> { ... }
    fn environment(&self, lua: &Lua) -> Result<Option<Table>> { ... }
    fn mode(&self) -> Option<ChunkMode> { ... }
}
Expand description

Trait for types loadable by Lua and convertible to a Chunk

Required Methods§

Source

fn source<'a>(&self) -> IoResult<Cow<'a, [u8]>>
where Self: 'a,

Returns chunk data (can be text or binary)

Provided Methods§

Source

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

Returns optional chunk name

See Chunk::set_name for possible name prefixes.

Source

fn environment(&self, lua: &Lua) -> Result<Option<Table>>

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 AsChunk for &str

Source§

fn source<'a>(&self) -> IoResult<Cow<'a, [u8]>>
where Self: 'a,

Source§

impl AsChunk for &String

Source§

fn source<'a>(&self) -> IoResult<Cow<'a, [u8]>>
where Self: 'a,

Source§

impl AsChunk for &Vec<u8>

Source§

fn source<'a>(&self) -> IoResult<Cow<'a, [u8]>>
where Self: 'a,

Source§

impl AsChunk for &Path

Source§

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

Source§

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

Source§

impl AsChunk for &[u8]

Source§

fn source<'a>(&self) -> IoResult<Cow<'a, [u8]>>
where Self: 'a,

Source§

impl AsChunk for String

Source§

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

Source§

impl AsChunk for Vec<u8>

Source§

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

Source§

impl AsChunk for PathBuf

Source§

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

Source§

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

Source§

impl<C: AsChunk + ?Sized> AsChunk for Box<C>

Source§

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

Source§

fn environment(&self, lua: &Lua) -> Result<Option<Table>>

Source§

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

Source§

fn source<'a>(&self) -> IoResult<Cow<'a, [u8]>>
where Self: 'a,

Implementors§