pub struct App {
pub rust_constructor_resource: Vec<RustConstructorResourceBox>,
pub tick_interval: f32,
pub current_page: String,
pub timer: Timer,
pub frame_times: Vec<f32>,
pub last_frame_time: Option<f32>,
pub basic_front_resource_list: Vec<String>,
pub render_layer: Vec<(RustConstructorId, [[f32; 2]; 2], bool)>,
pub active_list: Vec<RustConstructorId>,
pub render_list: Vec<RustConstructorId>,
}Expand description
This struct serves as the central hub for the Rust Constructor framework.
该结构体是Rust Constructor框架的中心枢纽。
Fields§
§rust_constructor_resource: Vec<RustConstructorResourceBox>Collection of all Rust Constructor resources with type-erased storage.
所有Rust Constructor资源的集合,使用类型擦除存储。
tick_interval: f32Refresh rate for resource updates in seconds.
资源更新的刷新率(秒)。
current_page: StringName of the current active page.
当前活动页面的名称。
timer: TimerTimer for tracking application runtime and page durations.
用于跟踪应用程序运行时间和页面持续时间的计时器。
frame_times: Vec<f32>Record of recent frame times for performance monitoring.
最近帧时间的记录,用于性能监控。
last_frame_time: Option<f32>Time taken to render the previous frame in seconds.
渲染上一帧所用的时间(秒)。
basic_front_resource_list: Vec<String>List of resource IDs that are basic front resources.
基本前端资源的资源ID列表。
This list should not be modified manually.
此列表不应手动修改。
render_layer: Vec<(RustConstructorId, [[f32; 2]; 2], bool)>Rendering layer information: (resource_id, [position, size], ignore_render_layer).
渲染层级信息:(资源ID, [位置, 尺寸], 是否忽略渲染层级)。
active_list: Vec<RustConstructorId>List of currently active resources.
当前活动的资源列表。
render_list: Vec<RustConstructorId>Queue of resources to be rendered in the current frame.
要在当前帧中呈现的资源队列。
Implementations§
Source§impl App
impl App
pub fn tick_interval(self, tick_interval: f32) -> Self
pub fn current_page(self, current_page: &str) -> Self
Sourcepub fn type_processor(&self, target: &impl RustConstructorResource) -> String
pub fn type_processor(&self, target: &impl RustConstructorResource) -> String
Sourcepub fn get_tag(
&self,
tag_name: &str,
target: &[[String; 2]],
) -> Option<(usize, String)>
pub fn get_tag( &self, tag_name: &str, target: &[[String; 2]], ) -> Option<(usize, String)>
Gets a tag value from the specified tag list by name.
从指定标签列表中根据名称获取标签值。
§Arguments
tag_name- The name of the tag to retrievetarget- The list of tags to search through
§Returns
Returns Some((index, value)) if the tag is found, or None if not found.
§参数
tag_name- 要检索的标签名称target- 要搜索的标签列表
§返回值
如果找到标签则返回Some((索引, 值)),否则返回None。
Sourcepub fn draw_resources(&mut self, ui: &mut Ui, ctx: &Context)
pub fn draw_resources(&mut self, ui: &mut Ui, ctx: &Context)
Draws all resources in the rendering queue at once, discarding all return values.
一次性绘制渲染队列中的所有资源,会丢弃所有返回值。
This method iterates through all resources in the render list and draws them. It’s not recommended for production use due to error handling limitations.
此方法遍历渲染列表中的所有资源并绘制它们。由于错误处理限制,不建议在生产环境中使用。
§Arguments
ui- The UI context for drawingctx- The rendering context
§参数
ui- 用于绘制的UI上下文ctx- 渲染上下文
Sourcepub fn draw_resource_by_index(
&mut self,
ui: &mut Ui,
ctx: &Context,
index: usize,
) -> Result<(), RustConstructorError>
pub fn draw_resource_by_index( &mut self, ui: &mut Ui, ctx: &Context, index: usize, ) -> Result<(), RustConstructorError>
Draws a specific resource by its index in the rendering queue.
根据资源在渲染队列中的索引值绘制特定资源。
This method handles the rendering of different resource types including:
- Images with various loading methods and transformations
- Text with formatting, selection, and hyperlink support
- Custom rectangles with borders and styling
此方法处理不同类型资源的渲染,包括:
- 具有各种加载方法和变换的图像
- 具有格式设置、选择和超链接支持的文本
- 具有边框和样式的自定义矩形
§Arguments
ui- The UI context for drawingctx- The rendering contextindex- The index of the resource in the render list
§Returns
Returns Ok(()) on success, or Err(RustConstructorError) if the resource
cannot be found or drawn.
§参数
ui- 用于绘制的UI上下文ctx- 渲染上下文index- 资源在渲染列表中的索引
§返回值
成功时返回Ok(()),如果资源无法找到或绘制则返回Err(RustConstructorError)。
Sourcepub fn active_list_info(&self, method: ActiveListInfoMethod) -> String
pub fn active_list_info(&self, method: ActiveListInfoMethod) -> String
Generates information about currently active resources.
生成当前活跃资源的信息。
This method returns a formatted string containing details about all resources in the active list. The level of detail depends on the specified method.
此方法返回一个格式化字符串,包含活动列表中所有资源的详细信息。 详细程度取决于指定的方法。
§Arguments
method- Determines the level of detail in the output
§Returns
A formatted string with resource information.
§参数
method- 决定输出信息的详细程度
§返回值
包含资源信息的格式化字符串。
Sourcepub fn render_layer_info(&self) -> String
pub fn render_layer_info(&self) -> String
Generates information about the current rendering layers.
This method returns a formatted string containing details about the rendering layer stack, including resource positions and rendering behavior.
§Returns
A formatted string with rendering layer information
生成当前渲染层级的信息。
此方法返回一个格式化字符串,包含渲染层级堆栈的详细信息, 包括资源位置和渲染行为。
§返回值
包含渲染层级信息的格式化字符串
Sourcepub fn render_list_info(&self) -> String
pub fn render_list_info(&self) -> String
Sourcepub fn update_render_list(&mut self)
pub fn update_render_list(&mut self)
Updates the render queue based on active resources.
根据活跃资源更新渲染队列。
This method synchronizes the render list with the active list, ensuring that only active basic front resources are included in the rendering queue.
此方法将渲染列表与活跃列表同步,确保只有活跃的基本前端资源包含在渲染队列中。
Sourcepub fn try_request_jump_render_list(
&mut self,
requester: RequestMethod,
request_type: RequestType,
)
pub fn try_request_jump_render_list( &mut self, requester: RequestMethod, request_type: RequestType, )
Attempts to move a resource to the front of the render queue, ignoring whether it exists.
请求在渲染队列中插队,且无视申请跳过队列的资源是否存在。
This is a safe wrapper around request_jump_render_list that suppresses errors.
Use when you want to attempt reordering without handling potential errors.
这是request_jump_render_list的安全包装器,会抑制错误。当您想要尝试重新排序而不处理潜在错误时使用。
§Arguments
requester- The resource to move in the queuerequest_type- How to move the resource (to top or up N layers)
§参数
requester- 要在队列中移动的资源request_type- 如何移动资源(到顶部或上移N层)
Sourcepub fn request_jump_render_list(
&mut self,
requester: RequestMethod,
request_type: RequestType,
) -> Result<(), RustConstructorError>
pub fn request_jump_render_list( &mut self, requester: RequestMethod, request_type: RequestType, ) -> Result<(), RustConstructorError>
Moves a resource to the front of the render queue with error handling.
将资源移动到渲染队列的前面(含错误处理)。
This method allows changing the rendering order of resources by moving a specific resource to the top of the queue or up a specified number of layers.
此方法允许通过将特定资源移动到队列顶部或上移指定层数来更改资源的渲染顺序。
§Arguments
requester- The resource to move in the queuerequest_type- How to move the resource (to top or up N layers)
§Returns
Returns Ok(()) on success, or Err(RustConstructorError) if the resource
cannot be found.
§参数
requester- 要在队列中移动的资源request_type- 如何移动资源(到顶部或上移N层)
§返回值
成功时返回Ok(()),如果资源无法找到则返回Err(RustConstructorError)。
Sourcepub fn jump_render_list_processor(
&mut self,
requester_index: usize,
request_type: RequestType,
) -> Result<(), RustConstructorError>
pub fn jump_render_list_processor( &mut self, requester_index: usize, request_type: RequestType, ) -> Result<(), RustConstructorError>
Handle the operation of skipping the rendering queue.
处理跳过渲染队列操作。
§Arguments
requester_index- The index of the resources to be moved in the queuerequest_type- How to move the resource (to top or up N layers)
§Returns
When successful, return Ok(()). If the index is out of bounds, return Err(RustConstructorError).
§参数
requester_index- 要在队列中移动的资源的索引request_type- 如何移动资源(到顶部或上移N层)
§返回值
成功时返回Ok(()),如果索引越界则返回Err(RustConstructorError)。
Sourcepub fn update_render_layer(&mut self)
pub fn update_render_layer(&mut self)
Updates the rendering layer information for all rendering resources.
更新所有渲染资源的渲染层信息。
This method recalculates the rendering layer by processing all resources in the render list and updating their position, size, and rendering properties.
此方法通过处理渲染列表中的所有资源并更新它们的位置、尺寸和渲染属性来重新计算渲染层级。
Sourcepub fn display_render_layer(
&self,
ui: &mut Ui,
render_config: &RenderConfig,
ignore_render_config: &RenderConfig,
)
pub fn display_render_layer( &self, ui: &mut Ui, render_config: &RenderConfig, ignore_render_config: &RenderConfig, )
Draw the rendering layer.
绘制渲染层。
This method can visually inspect the rendering status of all rendering resources and promptly correct any issues.
此方法可以直观检查所有渲染资源的渲染情况,并及时修正问题。
§Arguments
ui- The UI context for drawingrender_config- The config of the rendering layer areaignore_render- The config of ignore the rendering layer area
§参数
ui- 用于绘制的UI上下文render_config- 渲染层区域的配置ignore_render_config- 无视渲染层区域的配置
Sourcepub fn get_render_layer_resource(&self, id: &RustConstructorId) -> Option<usize>
pub fn get_render_layer_resource(&self, id: &RustConstructorId) -> Option<usize>
Sourcepub fn resource_get_focus(&self, index: usize, mouse_pos: [f32; 2]) -> bool
pub fn resource_get_focus(&self, index: usize, mouse_pos: [f32; 2]) -> bool
Check whether the resource has obtained the mouse focus.
检查资源是否获取鼠标焦点。
Use this method to ensure that mouse operations do not trigger multiple components simultaneously, causing confusion.
使用此方法以保证鼠标操作不会同时触发多个组件产生混乱。
§Arguments
index- The index value of the rendering resourcemouse_pos- The position of the mouse
§Returns
Return true if the resource is not blocked; otherwise, return false.
§参数
index- 渲染资源的索引值mouse_pos- 鼠标的位置
§返回值
如果资源未被阻挡,返回true,否则返回false。
Sourcepub fn add_active_resource(
&mut self,
id: &RustConstructorId,
) -> Result<(), RustConstructorError>
pub fn add_active_resource( &mut self, id: &RustConstructorId, ) -> Result<(), RustConstructorError>
Mark active resources.
标记活跃资源。
This method will be automatically called by the Rust Constructor without the need for manual control.
此方法会被Rust Constructor自动调用,无需手动控制。
§Arguments
id- The unique identifier of the resource
§Returns
When a success mark is made, return Ok(()), and when the resource is not found,
return Err(RustConstructorError).
§参数
id- 资源的唯一标识符
§返回值
成功标记时返回Ok(()),找不到资源时返回Err(RustConstructorError)。
Sourcepub fn add_resource<T: RustConstructorResource + 'static>(
&mut self,
name: &str,
resource: T,
) -> Result<(), RustConstructorError>
pub fn add_resource<T: RustConstructorResource + 'static>( &mut self, name: &str, resource: T, ) -> Result<(), RustConstructorError>
Adds a new resource to the application with the specified name.
添加一个新资源到应用程序中,并指定名称。
This method registers a resource instance with a unique name. If the name is already in use or invalid, an error is returned. For certain resource types like SplitTime, it automatically initializes time values.
此方法使用唯一名称注册资源实例。如果名称已存在或无效,则返回错误。 对于某些资源类型(如 SplitTime),它会自动初始化时间值。
§Arguments
name- A unique identifier for the resourceresource- The resource instance to add
§Returns
Returns Ok(()) on success, or Err(RustConstructorError) if the resource cannot be added.
§参数
name- 资源的唯一标识符resource- 要添加的资源实例
§返回值
成功时返回 Ok(()),如果资源无法添加则返回 Err(RustConstructorError)。
Sourcepub fn drop_resource(
&mut self,
id: &RustConstructorId,
) -> Result<(), RustConstructorError>
pub fn drop_resource( &mut self, id: &RustConstructorId, ) -> Result<(), RustConstructorError>
Removes a resource from the application. This method is very dangerous! Ensure the resource is no longer in use before deletion.
移除资源。此方法非常危险!务必确保资源一定不再使用后删除。
§Arguments
id- The unique identifier of the resource
§Returns
Returns Ok(()) on success, or Err(RustConstructorError) if the resource cannot be found.
§参数
id- 资源的唯一标识符
§返回值
成功时返回 Ok(()),如果资源无法找到则返回 Err(RustConstructorError)。
Sourcepub fn replace_resource<T>(
&mut self,
name: &str,
resource: T,
) -> Result<(), RustConstructorError>where
T: RustConstructorResource + 'static,
pub fn replace_resource<T>(
&mut self,
name: &str,
resource: T,
) -> Result<(), RustConstructorError>where
T: RustConstructorResource + 'static,
Replaces an existing resource with a new one in the application.
用应用程序中的新资源替换现有资源。
§Arguments
name- The name of the resource to replaceresource- The new resource instance
§Returns
Returns Ok(()) on success, or Err(RustConstructorError) if the resource cannot be found or replaced.
§参数
name- 要替换的资源名称resource- 新的资源实例
§返回值
成功时返回 Ok(()),如果资源无法找到或替换则返回 Err(RustConstructorError)。
Sourcepub fn get_box_resource(
&self,
id: &RustConstructorId,
) -> Result<&dyn RustConstructorResource, RustConstructorError>
pub fn get_box_resource( &self, id: &RustConstructorId, ) -> Result<&dyn RustConstructorResource, RustConstructorError>
Obtain the boxed immutable resources from the list.
从列表中获取封装的不可变资源。
If you need to use a resource without knowing its type, please use this method to retrieve the resource.
如果需要在不知道类型的情况下使用资源,请使用此方法取出资源。
§Arguments
id- The unique identifier of the resource
§Returns
If the resource is found, return the reference of the resource; otherwise, return Err(RustConstructorError).
§参数
id- 资源的唯一标识符
§返回值
如果找到资源,返回资源的引用,否则返回Err(RustConstructorError)。
Sourcepub fn get_box_resource_mut(
&mut self,
id: &RustConstructorId,
) -> Result<&mut dyn RustConstructorResource, RustConstructorError>
pub fn get_box_resource_mut( &mut self, id: &RustConstructorId, ) -> Result<&mut dyn RustConstructorResource, RustConstructorError>
Obtain the boxed mutable resources from the list.
从列表中获取封装的可变资源。
If you need to use a resource without knowing its type, please use this method to retrieve the resource.
如果需要在不知道类型的情况下使用资源,请使用此方法取出资源。
§Arguments
id- The unique identifier of the resource
§Returns
If the resource is found, return the mutable reference of the resource; otherwise, return Err(RustConstructorError).
§参数
id- 资源的唯一标识符
§返回值
如果找到资源,返回资源的可变引用,否则返回Err(RustConstructorError)。
Sourcepub fn get_resource<T>(
&self,
id: &RustConstructorId,
) -> Result<&T, RustConstructorError>where
T: RustConstructorResource + 'static,
pub fn get_resource<T>(
&self,
id: &RustConstructorId,
) -> Result<&T, RustConstructorError>where
T: RustConstructorResource + 'static,
Sourcepub fn get_resource_mut<T>(
&mut self,
id: &RustConstructorId,
) -> Result<&mut T, RustConstructorError>where
T: RustConstructorResource + 'static,
pub fn get_resource_mut<T>(
&mut self,
id: &RustConstructorId,
) -> Result<&mut T, RustConstructorError>where
T: RustConstructorResource + 'static,
Sourcepub fn check_resource_exists(&self, id: &RustConstructorId) -> Option<usize>
pub fn check_resource_exists(&self, id: &RustConstructorId) -> Option<usize>
Sourcepub fn quick_place<T: RustConstructorResource + 'static>(
&mut self,
name: &str,
resource: T,
ui: &mut Ui,
ctx: &Context,
) -> Result<(), RustConstructorError>
pub fn quick_place<T: RustConstructorResource + 'static>( &mut self, name: &str, resource: T, ui: &mut Ui, ctx: &Context, ) -> Result<(), RustConstructorError>
Quickly adds and uses a resource in one operation.
快速添加并使用资源。
This method combines adding a resource to the application and immediately using it.
此方法将资源添加到应用程序并立即使用它。
§Arguments
name- The name for the resourceresource- The resource instance to add and drawui- The UI context for drawingctx- The rendering context
§Returns
Returns Ok(()) on success, or Err(RustConstructorError) if the resource cannot be added or drawn.
§参数
name- 资源的名称resource- 要添加和绘制的资源实例ui- 用于绘制的UI上下文ctx- 渲染上下文
§返回值
成功时返回 Ok(()),如果资源无法添加或绘制则返回 Err(RustConstructorError)。
Sourcepub fn use_resource(
&mut self,
id: &RustConstructorId,
ui: &mut Ui,
ctx: &Context,
) -> Result<(), RustConstructorError>
pub fn use_resource( &mut self, id: &RustConstructorId, ui: &mut Ui, ctx: &Context, ) -> Result<(), RustConstructorError>
Use the existing resources.
使用已存在的资源。
This method invokes existing resources and performs operations.
此方法调用存在的资源并进行操作。
§Arguments
id- The unique identifier of the resourceui- The UI context for drawingctx- The rendering context
§Returns
Returns Ok(()) on success, or Err(RustConstructorError) if the resource cannot be handled.
§参数
id- 资源的唯一标识符ui- 用于绘制的UI上下文ctx- 渲染上下文
§返回值
成功时返回 Ok(()),如果资源无法处理则返回 Err(RustConstructorError)。
Sourcepub fn switch_page(&mut self, name: &str) -> Result<(), RustConstructorError>
pub fn switch_page(&mut self, name: &str) -> Result<(), RustConstructorError>
Switches to a different page and resets page-specific state.
切换到不同页面并重置页面特定状态。
§Arguments
name- The name of the page to switch to
§Returns
Returns Ok(()) on success, or Err(RustConstructorError) if the page cannot be found.
§参数
name- 要切换到的页面名称
§返回值
成功时返回 Ok(()),如果页面无法找到则返回 Err(RustConstructorError)。
Sourcepub fn get_font(
&self,
name: &str,
) -> Result<FontDefinitions, RustConstructorError>
pub fn get_font( &self, name: &str, ) -> Result<FontDefinitions, RustConstructorError>
Sourcepub fn register_all_fonts(&self, ctx: &Context)
pub fn register_all_fonts(&self, ctx: &Context)
Registers all font resources with the egui context.
向egui上下文中注册所有字体资源。
This method loads and registers all fonts that have been added to the application with the egui rendering system for text display.
此方法加载并注册应用程序中已添加的所有字体到egui渲染系统中,用于文本显示。
§Arguments
ctx- The egui context for font registration
§参数
ctx- 用于字体注册的egui上下文
Sourcepub fn position_size_processor(
&self,
position_size_config: PositionSizeConfig,
ctx: &Context,
) -> [[f32; 2]; 2]
pub fn position_size_processor( &self, position_size_config: PositionSizeConfig, ctx: &Context, ) -> [[f32; 2]; 2]
Processes position and size calculations for resources.
处理资源的最基本位置和尺寸计算。
This method handles the complex positioning logic including grid-based layout, alignment, and offset calculations for UI resources.
此方法处理复杂的定位逻辑,包括基于网格的布局、对齐方式和UI资源的偏移计算。
§Arguments
position_size_config- The configuration for position and sizectx- The egui context for available space calculations
§Returns
Returns [position, size] as computed from the configuration
§参数
position_size_config- 位置和尺寸的配置ctx- 用于可用空间计算的egui上下文
§返回值
返回根据配置计算出的 [位置, 尺寸]
Sourcepub fn check_updated(
&mut self,
name: &str,
) -> Result<bool, RustConstructorError>
pub fn check_updated( &mut self, name: &str, ) -> Result<bool, RustConstructorError>
Checks if a page has completed its initial loading phase.
检查页面是否已完成首次加载。
§Arguments
name- The name of the page to check
§Returns
Returns Ok(true) if the page has completed loading, or Ok(false) if the page has not completed loading.
Returns Err(RustConstructorError) if the page cannot be found.
§参数
name- 要检查的页面名称
§返回值
如果页面已完成加载则返回 Ok(true),如果未加载则返回 Ok(false)。
如果页面无法找到则返回 Err(RustConstructorError)。
Sourcepub fn check_enter_updated(
&mut self,
name: &str,
) -> Result<bool, RustConstructorError>
pub fn check_enter_updated( &mut self, name: &str, ) -> Result<bool, RustConstructorError>
Checks if a page has completed its enter transition.
检查页面是否已完成进入过渡。
§Arguments
name- The name of the page to check
§Returns
Returns Ok(true) if the page has completed entering, or Ok(false) if the page has not completed entering.
Returns Err(RustConstructorError) if the page cannot be found.
§参数
name- 要检查的页面名称
§返回值
如果页面已完成进入则返回 Ok(true),如果未过渡则返回 Ok(false)。
如果页面无法找到则返回 Err(RustConstructorError)。
Sourcepub fn new_page_update(
&mut self,
name: &str,
) -> Result<(), RustConstructorError>
pub fn new_page_update( &mut self, name: &str, ) -> Result<(), RustConstructorError>
Updates when entering a new page.
进入新页面时的更新。
This method is used to ensure the accuracy of the content based on the page, and the Rust Constructor will automatically call this method.
此方法用于确保基于页面的内容的准确性,Rust Constructor会自动调用此方法。
§Arguments
name- The name of the page to be updated
§Returns
If the update is successful, return Ok(()); if the resource is not found, return Err(RustConstructorError).
§参数
name- 要更新的页面名称
§返回值
如果更新成功则返回Ok(()),找不到资源则返回Err(RustConstructorError)。
Sourcepub fn update_frame_stats(&mut self)
pub fn update_frame_stats(&mut self)
Updates frame timing statistics for performance monitoring.
更新帧数统计信息用于性能监控。
This method maintains a rolling window of frame times and calculates performance metrics like frame rate.
此方法维护帧时间的滚动窗口并计算帧率等性能指标。
Sourcepub fn current_fps(&self) -> f32
pub fn current_fps(&self) -> f32
Sourcepub fn reset_split_time(
&mut self,
name: &str,
) -> Result<(), RustConstructorError>
pub fn reset_split_time( &mut self, name: &str, ) -> Result<(), RustConstructorError>
Resets the split time for a specific resource.
重置特定资源的分段计时器。
§Arguments
name- The name of the split time resource to reset
§Returns
Returns Ok(()) on success, or Err(RustConstructorError) if the resource cannot be found.
§参数
name- 要重置的分段时间资源名称
§返回值
成功时返回 Ok(()),如果资源无法找到则返回 Err(RustConstructorError)。
Sourcepub fn get_split_time(
&self,
name: &str,
) -> Result<[f32; 2], RustConstructorError>
pub fn get_split_time( &self, name: &str, ) -> Result<[f32; 2], RustConstructorError>
Retrieves the timing information from a split time resource.
获取分段计时器资源的时间信息。
§Arguments
name- The name of the split time resource
§Returns
Returns Ok([page_runtime, total_runtime]) if found, or Err(RustConstructorError) if not found.
§参数
name- 分段计时器资源的名称
§返回值
如果找到则返回 Ok([页面运行时间, 总运行时间]),否则返回 Err(RustConstructorError)。
Sourcepub fn update_timer(&mut self)
pub fn update_timer(&mut self)
Updates the application timer with current timing information.
更新应用程序计时器的当前时间信息。
This method updates both the total runtime and current page runtime.
此方法更新总运行时间和当前页面运行时间。
Sourcepub fn modify_variable<T: Debug + 'static>(
&mut self,
name: &str,
value: Option<T>,
) -> Result<(), RustConstructorError>
pub fn modify_variable<T: Debug + 'static>( &mut self, name: &str, value: Option<T>, ) -> Result<(), RustConstructorError>
Modifies the value of a variable resource.
修改变量资源的值。
§Arguments
name- The name of the variable resourcevalue- The new value to set (useNoneto clear)
§Returns
Returns Ok(()) on success, or Err(RustConstructorError) if the resource cannot be found.
§参数
name- 变量资源的名称value- 要设置的新值(使用None来清除)
§返回值
成功时返回 Ok(()),如果资源无法找到则返回 Err(RustConstructorError)。
Sourcepub fn get_variable<T: Debug + Clone + 'static>(
&self,
name: &str,
) -> Result<Option<T>, RustConstructorError>
pub fn get_variable<T: Debug + Clone + 'static>( &self, name: &str, ) -> Result<Option<T>, RustConstructorError>
Sourcepub fn set_switch_enable(
&mut self,
name: &str,
enable: bool,
) -> Result<(), RustConstructorError>
pub fn set_switch_enable( &mut self, name: &str, enable: bool, ) -> Result<(), RustConstructorError>
Modify the enable status of the switch.
修改开关的启用状态。
§Arguments
name- The name of the switch resourceenable- The new enable status
§Returns
Returns Ok(()) on success, or Err(RustConstructorError) if the resource cannot be found.
§参数
name- 开关资源的名称enable- 新的启用状态
§返回值
成功时返回 Ok(()),如果资源无法找到则返回 Err(RustConstructorError)。
Sourcepub fn check_switch_data(
&self,
name: &str,
) -> Result<SwitchData, RustConstructorError>
pub fn check_switch_data( &self, name: &str, ) -> Result<SwitchData, RustConstructorError>
Retrieves the current state and interaction data from a switch resource.
获取开关资源的当前状态和交互数据。
§Arguments
name- The name of the switch resource
§Returns
Returns Ok(SwitchData) containing the switch state and interaction history,
or Err(RustConstructorError) if the resource cannot be found.
§参数
name- 开关资源的名称
§返回值
返回包含开关状态和交互历史的 Ok(SwitchData),
如果资源无法找到则返回 Err(RustConstructorError)。
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 UnsafeUnpin 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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().