pub struct PrintOptions {
pub css: Option<String>,
pub fallback: Option<String>,
}Expand description
Options of [print].
Fields§
§css: Option<String>A stylesheet for the view.
fallback: Option<String>Text to write instead of the plain rendering when TSP isn’t available.
Implementations§
Source§impl PrintOptions
impl PrintOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
No stylesheet, the plain rendering as fallback.
Examples found in repository?
examples/table.rs (line 93)
80fn main() -> Result<(), tern_sdk::Error> {
81 let mut entries: Vec<Entry> = fs::read_dir(".")?
82 .filter_map(Result::ok)
83 .filter_map(|e| {
84 let meta = e.metadata().ok()?;
85 Some(Entry {
86 name: e.file_name().to_string_lossy().into_owned(),
87 dir: meta.is_dir(),
88 size: meta.len(),
89 })
90 })
91 .collect();
92 entries.sort_by(|a, b| b.dir.cmp(&a.dir).then_with(|| a.name.cmp(&b.name)));
93 tern_sdk::print(view(&entries), PrintOptions::new().css(CSS))
94}Sourcepub fn css(self, css: impl Into<String>) -> Self
pub fn css(self, css: impl Into<String>) -> Self
Sets the stylesheet.
Examples found in repository?
examples/table.rs (line 93)
80fn main() -> Result<(), tern_sdk::Error> {
81 let mut entries: Vec<Entry> = fs::read_dir(".")?
82 .filter_map(Result::ok)
83 .filter_map(|e| {
84 let meta = e.metadata().ok()?;
85 Some(Entry {
86 name: e.file_name().to_string_lossy().into_owned(),
87 dir: meta.is_dir(),
88 size: meta.len(),
89 })
90 })
91 .collect();
92 entries.sort_by(|a, b| b.dir.cmp(&a.dir).then_with(|| a.name.cmp(&b.name)));
93 tern_sdk::print(view(&entries), PrintOptions::new().css(CSS))
94}Trait Implementations§
Source§impl Clone for PrintOptions
impl Clone for PrintOptions
Source§impl Debug for PrintOptions
impl Debug for PrintOptions
Auto Trait Implementations§
impl Freeze for PrintOptions
impl RefUnwindSafe for PrintOptions
impl Send for PrintOptions
impl Sync for PrintOptions
impl Unpin for PrintOptions
impl UnsafeUnpin for PrintOptions
impl UnwindSafe for PrintOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more