Skip to main content

LuaWriter

Struct LuaWriter 

Source
pub struct LuaWriter<W: Write> { /* private fields */ }
Expand description

An Nsi sink that writes each call straight to a Lua script.

The Lua twin of crate::StreamWriter, and the writing half of a filter whose output is a script rather than a stream. Every restriction write_lua documents applies here and for the same reason: the binding is narrower than the C API, so a call it cannot say is refused rather than emitted as something else.

let writer = LuaWriter::new(Vec::new());
writer.create("cam", "perspectivecamera", None).unwrap();
assert_eq!(
    String::from_utf8(writer.into_inner()).unwrap(),
    "nsi.Create(\"cam\", \"perspectivecamera\")\n",
);

Implementations§

Source§

impl<W: Write> LuaWriter<W>

Source

pub fn new(out: W) -> Self

A writer emitting into out.

Source

pub fn into_inner(self) -> W

The out this was built with.

Trait Implementations§

Source§

impl<W: Debug + Write> Debug for LuaWriter<W>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<W: Write + Send> Nsi for LuaWriter<W>

Source§

fn create( &self, handle: &str, node_type: &str, args: Option<&[Self::Arg<'_>]>, ) -> Result<(), Self::Error>

§Errors

LuaError::CreateArguments when the create carries parameters: nsi.Create has nowhere to put them.

Source§

fn render_control( &self, action: Action, args: Option<&[Self::Arg<'_>]>, ) -> Result<(), Self::Error>

The action is written as the "action" parameter ɴsɪ’s Lua binding reads, and one that arrived in args is dropped – crate::StreamWriter::render_control says why.

Source§

type Arg<'call> = Arg<'call, 'static>

Argument type – each implementor picks its own. Read more
Source§

type Error = LuaError

Error type for fallible operations.
Source§

fn delete( &self, handle: &str, args: Option<&[Self::Arg<'_>]>, ) -> Result<(), Self::Error>

Delete a node from the scene graph.
Source§

fn set_attribute( &self, handle: &str, args: &[Self::Arg<'_>], ) -> Result<(), Self::Error>

Set attributes on a node.
Source§

fn set_attribute_at_time( &self, handle: &str, time: f64, args: &[Self::Arg<'_>], ) -> Result<(), Self::Error>

Set attributes on a node at a specific time (for motion blur).
Source§

fn delete_attribute(&self, handle: &str, name: &str) -> Result<(), Self::Error>

Delete an attribute from a node.
Source§

fn connect( &self, from: &str, from_attribute: Option<&str>, to: &str, to_attribute: &str, args: Option<&[Self::Arg<'_>]>, ) -> Result<(), Self::Error>

Connect two nodes in the scene graph.
Source§

fn disconnect( &self, from: &str, from_attribute: Option<&str>, to: &str, to_attribute: &str, ) -> Result<(), Self::Error>

Disconnect two nodes in the scene graph.
Source§

fn evaluate(&self, args: &[Self::Arg<'_>]) -> Result<(), Self::Error>

Evaluate procedural nodes or Lua scripts.

Auto Trait Implementations§

§

impl<W> !Freeze for LuaWriter<W>

§

impl<W> !RefUnwindSafe for LuaWriter<W>

§

impl<W> Send for LuaWriter<W>
where Mutex<RawMutex, W>: Send,

§

impl<W> Sync for LuaWriter<W>
where Mutex<RawMutex, W>: Sync,

§

impl<W> Unpin for LuaWriter<W>
where Mutex<RawMutex, W>: Unpin,

§

impl<W> UnsafeUnpin for LuaWriter<W>

§

impl<W> UnwindSafe for LuaWriter<W>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.