Skip to main content

StreamWriter

Struct StreamWriter 

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

An Nsi sink that writes each call straight to a .nsi stream.

This is the writing half of a filter: nsi-parse reads a stream into any Nsi sink, and this writes one back out. A consumer that puts its own Nsi implementation between the two sees every call as it goes past and decides what to forward – 3Delight’s nsicallbacks.h in Rust, with a Result where it has a bool.

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

§Not write_stream

write_stream replays a Scene, which is state: it emits each attribute once, in node order, whatever calls produced it. This emits the calls, in the order they arrive, holding nothing – so a re-set attribute appears twice, a stream keeps its shape, and the memory cost is one statement rather than one scene.

Implementations§

Source§

impl<W: Write> StreamWriter<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 StreamWriter<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 StreamWriter<W>

Source§

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

The Arg every sink in this workspace speaks, so a filter can forward what it was handed without rebuilding it.

Source§

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

The action is written from the typed Action, and an "action" parameter that arrived in args is dropped.

The stream carries the action as a parameter and the trait as an enum. nsi-parse strips the parameter and passes the enum, and nsi-ffi-wrap’s Context appends it again on the way out, so writing both would put two "action"s in one statement – and writing neither leaves a RenderControl 3Delight rejects.

Source§

type Error = Error

Error type for fallible operations.
Source§

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

Create a new node in the scene graph.
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 StreamWriter<W>

§

impl<W> !RefUnwindSafe for StreamWriter<W>

§

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

§

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

§

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

§

impl<W> UnsafeUnpin for StreamWriter<W>

§

impl<W> UnwindSafe for StreamWriter<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.