pub struct App { /* private fields */ }
Implementations§
Source§impl App
impl App
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
83fn comparison_example() {
84 println!("\n=== 传统方式 vs app! 宏对比 ===");
85
86 println!("传统方式(较冗长):");
87 println!("App::new()");
88 println!(" .set_entry_file(\"main.ppl\")");
89 println!(" .add_plugin(BuiltinPlugin)");
90 println!(" .add_plugin(MathPlugin)");
91 println!(" .add_plugin(FormatStringPlugin)");
92 println!(" .run();");
93
94 println!("\n使用 app! 宏(简洁):");
95 println!("app!(\"main.ppl\", [BuiltinPlugin, MathPlugin, FormatStringPlugin])");
96 println!(" .run();");
97
98 // 实际创建两个等效的应用程序进行对比
99 use pipeline_script::core::app::App;
100
101 // 传统方式
102 let _traditional_app = App::new()
103 .set_entry_file("compare.ppl")
104 .add_plugin(BuiltinPlugin)
105 .add_plugin(MathPlugin);
106
107 // 使用宏
108 let _macro_app = app!("compare.ppl", [BuiltinPlugin, MathPlugin]);
109
110 println!("\n两种方式创建的应用程序功能完全相同!");
111}
pub fn register_external_function(self, name: &str, func: *mut c_void) -> Self
Sourcepub fn set_test_llvm(self, test: bool) -> Self
pub fn set_test_llvm(self, test: bool) -> Self
Examples found in repository?
25fn chaining_example() {
26 println!("\n=== 链式调用示例 ===");
27
28 // 使用 app! 宏创建应用程序,然后链式调用其他配置方法
29 let _configured_app = app!(
30 "complex.ppl",
31 [BuiltinPlugin, FormatStringPlugin, MathPlugin, MapPlugin]
32 )
33 .set_test_llvm(true)
34 .add_test_llvm_file("test.ll");
35
36 // .run(); // 注释掉避免实际执行
37
38 println!("配置完成的应用程序:");
39 println!(" - 入口文件: 'complex.ppl'");
40 println!(" - 插件: BuiltinPlugin, FormatStringPlugin, MathPlugin, MapPlugin");
41 println!(" - LLVM测试: 已启用");
42 println!(" - 测试文件: 'test.ll'");
43}
Sourcepub fn add_test_llvm_file(self, path: impl AsRef<Path>) -> Self
pub fn add_test_llvm_file(self, path: impl AsRef<Path>) -> Self
Examples found in repository?
25fn chaining_example() {
26 println!("\n=== 链式调用示例 ===");
27
28 // 使用 app! 宏创建应用程序,然后链式调用其他配置方法
29 let _configured_app = app!(
30 "complex.ppl",
31 [BuiltinPlugin, FormatStringPlugin, MathPlugin, MapPlugin]
32 )
33 .set_test_llvm(true)
34 .add_test_llvm_file("test.ll");
35
36 // .run(); // 注释掉避免实际执行
37
38 println!("配置完成的应用程序:");
39 println!(" - 入口文件: 'complex.ppl'");
40 println!(" - 插件: BuiltinPlugin, FormatStringPlugin, MathPlugin, MapPlugin");
41 println!(" - LLVM测试: 已启用");
42 println!(" - 测试文件: 'test.ll'");
43}
pub fn register_visitor(self, visitor: impl Visitor + 'static) -> Self
Sourcepub fn add_plugin(self, plugin: impl Plugin) -> Self
pub fn add_plugin(self, plugin: impl Plugin) -> Self
Examples found in repository?
83fn comparison_example() {
84 println!("\n=== 传统方式 vs app! 宏对比 ===");
85
86 println!("传统方式(较冗长):");
87 println!("App::new()");
88 println!(" .set_entry_file(\"main.ppl\")");
89 println!(" .add_plugin(BuiltinPlugin)");
90 println!(" .add_plugin(MathPlugin)");
91 println!(" .add_plugin(FormatStringPlugin)");
92 println!(" .run();");
93
94 println!("\n使用 app! 宏(简洁):");
95 println!("app!(\"main.ppl\", [BuiltinPlugin, MathPlugin, FormatStringPlugin])");
96 println!(" .run();");
97
98 // 实际创建两个等效的应用程序进行对比
99 use pipeline_script::core::app::App;
100
101 // 传统方式
102 let _traditional_app = App::new()
103 .set_entry_file("compare.ppl")
104 .add_plugin(BuiltinPlugin)
105 .add_plugin(MathPlugin);
106
107 // 使用宏
108 let _macro_app = app!("compare.ppl", [BuiltinPlugin, MathPlugin]);
109
110 println!("\n两种方式创建的应用程序功能完全相同!");
111}
pub fn run(&mut self)
Sourcepub fn set_entry_file(self, path: impl AsRef<Path>) -> Self
pub fn set_entry_file(self, path: impl AsRef<Path>) -> Self
Examples found in repository?
83fn comparison_example() {
84 println!("\n=== 传统方式 vs app! 宏对比 ===");
85
86 println!("传统方式(较冗长):");
87 println!("App::new()");
88 println!(" .set_entry_file(\"main.ppl\")");
89 println!(" .add_plugin(BuiltinPlugin)");
90 println!(" .add_plugin(MathPlugin)");
91 println!(" .add_plugin(FormatStringPlugin)");
92 println!(" .run();");
93
94 println!("\n使用 app! 宏(简洁):");
95 println!("app!(\"main.ppl\", [BuiltinPlugin, MathPlugin, FormatStringPlugin])");
96 println!(" .run();");
97
98 // 实际创建两个等效的应用程序进行对比
99 use pipeline_script::core::app::App;
100
101 // 传统方式
102 let _traditional_app = App::new()
103 .set_entry_file("compare.ppl")
104 .add_plugin(BuiltinPlugin)
105 .add_plugin(MathPlugin);
106
107 // 使用宏
108 let _macro_app = app!("compare.ppl", [BuiltinPlugin, MathPlugin]);
109
110 println!("\n两种方式创建的应用程序功能完全相同!");
111}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for App
impl !RefUnwindSafe for App
impl !Send for App
impl !Sync for App
impl Unpin for App
impl !UnwindSafe for App
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
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute
value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
Quirk
value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition
value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);