IoWriter

Struct IoWriter 

Source
pub struct IoWriter<W>(pub W);
Expand description

Io writer.

Helper which adapts to any std::io::Write objects such as stdout.

Tuple Fields§

§0: W

Implementations§

Source§

impl IoWriter<Stdout>

Source

pub fn stdout() -> IoWriter<Stdout>

Examples found in repository?
examples/nesting-techniques.rs (line 69)
50fn main() {
51	let mut nested = Nested::default();
52
53	// This property appears nested but is set in the parent context
54	cvar::console::set_value(&mut nested, "foo.bool", &true, &mut cvar::NullWriter);
55	assert!(nested.boolean);
56
57	println!("Hit enter to list all the cvars and their values.");
58	println!("Assign value to cvar with `<name> <value>`.");
59
60	loop {
61		// Read input from stdin
62		let mut line = String::new();
63		if read_line(&mut line) {
64			break;
65		}
66
67		// Crude command line parsing
68		let (path, args) = split_line(&line);
69		cvar::console::poke(&mut nested, path, args, &mut cvar::IoWriter::stdout());
70	}
71}
More examples
Hide additional examples
examples/runtime-properties.rs (line 93)
64fn main() {
65	let mut runtime_props = RuntimeProps::default();
66
67	// Create some runtime props
68	let mut writer = String::new();
69	cvar::console::invoke(&mut runtime_props, "create!", "float f 3.141592", &mut writer);
70	cvar::console::invoke(&mut runtime_props, "create!", "string s Hello World!", &mut writer);
71	cvar::console::invoke(&mut runtime_props, "create!", "int i 42", &mut writer);
72
73	// Inspect the underlying props
74	assert_eq!(runtime_props.props.len(), 3);
75	assert_eq!(runtime_props.props[0].get_value().to_string(), "3.141592");
76	assert_eq!(runtime_props.props[1].get_value().to_string(), "Hello World!");
77	assert_eq!(runtime_props.props[2].get_value().to_string(), "42");
78
79	println!("Hit enter to list all the cvars and their values.");
80	println!("Assign value to cvar with `<name> <value>`.");
81	println!("Create new cvars with `create! <type> <name> <value>`.");
82	println!("Destroy the cvars with `destroy! <name>.");
83
84	loop {
85		// Read input from stdin
86		let mut line = String::new();
87		if read_line(&mut line) {
88			break;
89		}
90
91		// Crude command line parsing
92		let (path, args) = split_line(&line);
93		cvar::console::poke(&mut runtime_props, path, args, &mut cvar::IoWriter::stdout());
94	}
95}
Source§

impl IoWriter<Stderr>

Trait Implementations§

Source§

impl<W: Write> Write for IoWriter<W>

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result

Glue for usage of the write! macro with implementors of this trait. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
Source§

impl<W: Write + 'static> IWrite for IoWriter<W>

Auto Trait Implementations§

§

impl<W> Freeze for IoWriter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for IoWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for IoWriter<W>
where W: Send,

§

impl<W> Sync for IoWriter<W>
where W: Sync,

§

impl<W> Unpin for IoWriter<W>
where W: Unpin,

§

impl<W> UnwindSafe for IoWriter<W>
where W: UnwindSafe,

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.