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>
impl<W: Write> StreamWriter<W>
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
The out this was built with.
Trait Implementations§
Source§impl<W: Write + Send> Nsi for StreamWriter<W>
impl<W: Write + Send> Nsi for StreamWriter<W>
Source§type Arg<'call> = Arg<'call, 'static>
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>
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.