Skip to main content

App

Struct App 

Source
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: f32

Refresh rate for resource updates in seconds.

资源更新的刷新率(秒)。

§current_page: String

Name of the current active page.

当前活动页面的名称。

§timer: Timer

Timer 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

Source

pub fn tick_interval(self, tick_interval: f32) -> Self

Source

pub fn current_page(self, current_page: &str) -> Self

Source

pub fn type_processor(&self, target: &impl RustConstructorResource) -> String

Obtain the type name of the target resource.

获取目标资源的类型名称。

§Arguments
  • target - Target resource
§Returns

Returns the type name of the target resource.

§参数
  • target - 目标资源
§返回

目标资源的类型名称。

Source

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 retrieve
  • target - 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

Source

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 drawing
  • ctx - The rendering context
§参数
  • ui - 用于绘制的UI上下文
  • ctx - 渲染上下文
Source

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 drawing
  • ctx - The rendering context
  • index - 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)

Source

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 - 决定输出信息的详细程度
§返回值

包含资源信息的格式化字符串。

Source

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

生成当前渲染层级的信息。

此方法返回一个格式化字符串,包含渲染层级堆栈的详细信息, 包括资源位置和渲染行为。

§返回值

包含渲染层级信息的格式化字符串

Source

pub fn render_list_info(&self) -> String

Generates information about the current render queue.

生成当前渲染队列的信息。

This method returns a formatted string listing all resources in the render queue with their names and types.

此方法返回一个格式化字符串,列出渲染队列中的所有资源及其名称和类型。

§Returns

A formatted string with render queue information.

§返回值

包含渲染队列信息的格式化字符串。

Source

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.

此方法将渲染列表与活跃列表同步,确保只有活跃的基本前端资源包含在渲染队列中。

Source

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 queue
  • request_type - How to move the resource (to top or up N layers)
§参数
  • requester - 要在队列中移动的资源
  • request_type - 如何移动资源(到顶部或上移N层)
Source

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 queue
  • request_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)

Source

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 queue
  • request_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)

Source

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.

此方法通过处理渲染列表中的所有资源并更新它们的位置、尺寸和渲染属性来重新计算渲染层级。

Source

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 drawing
  • render_config - The config of the rendering layer area
  • ignore_render - The config of ignore the rendering layer area
§参数
  • ui - 用于绘制的UI上下文
  • render_config - 渲染层区域的配置
  • ignore_render_config - 无视渲染层区域的配置
Source

pub fn get_render_layer_resource(&self, id: &RustConstructorId) -> Option<usize>

Search for resources in the render list by ID.

通过ID在渲染列表中查找资源。

§Arguments
  • id - The ID of the resource to search for
§Returns

The index of the resource in the render list, or None if not found

§参数
  • id - 要查找的资源的ID
§返回值

渲染列表中的资源索引,如果没有找到则为None

Source

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 resource
  • mouse_pos - The position of the mouse
§Returns

Return true if the resource is not blocked; otherwise, return false.

§参数
  • index - 渲染资源的索引值
  • mouse_pos - 鼠标的位置
§返回值

如果资源未被阻挡,返回true,否则返回false。

Source

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)

Source

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 resource
  • resource - The resource instance to add
§Returns

Returns Ok(()) on success, or Err(RustConstructorError) if the resource cannot be added.

§参数
  • name - 资源的唯一标识符
  • resource - 要添加的资源实例
§返回值

成功时返回 Ok(()),如果资源无法添加则返回 Err(RustConstructorError)

Source

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)

Source

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 replace
  • resource - 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)

Source

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)

Source

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)

Source

pub fn get_resource<T>( &self, id: &RustConstructorId, ) -> Result<&T, RustConstructorError>
where T: RustConstructorResource + 'static,

Obtain the immutable resources from the list.

从列表中获取不可变资源。

§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)

Source

pub fn get_resource_mut<T>( &mut self, id: &RustConstructorId, ) -> Result<&mut T, RustConstructorError>
where T: RustConstructorResource + 'static,

Obtain the mutable resources from the list.

从列表中获取可变资源。

§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)

Source

pub fn check_resource_exists(&self, id: &RustConstructorId) -> Option<usize>

Checks if a specific resource exists in the application.

检查应用程序中是否存在特定资源。

§Arguments
  • id - The unique identifier of the resource
§Returns

Returns Some(index) if the resource exists, or None if not found.

§参数
  • id - 资源的唯一标识符
§返回值

如果资源存在则返回 Some(索引),否则返回 None

Source

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 resource
  • resource - The resource instance to add and draw
  • ui - The UI context for drawing
  • ctx - 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)

Source

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 resource
  • ui - The UI context for drawing
  • ctx - The rendering context
§Returns

Returns Ok(()) on success, or Err(RustConstructorError) if the resource cannot be handled.

§参数
  • id - 资源的唯一标识符
  • ui - 用于绘制的UI上下文
  • ctx - 渲染上下文
§返回值

成功时返回 Ok(()),如果资源无法处理则返回 Err(RustConstructorError)

Source

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)

Source

pub fn get_font( &self, name: &str, ) -> Result<FontDefinitions, RustConstructorError>

Retrieves font definitions for a font resource.

获取字体资源的字体定义。

§Arguments
  • name - The name of the font resource
§Returns

Returns Ok(FontDefinitions) if the font exists, or Err(RustConstructorError) if not found.

§参数
  • name - 字体资源的名称
§返回值

如果字体存在则返回 Ok(FontDefinitions),否则返回 Err(RustConstructorError)

Source

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上下文
Source

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 size
  • ctx - The egui context for available space calculations
§Returns

Returns [position, size] as computed from the configuration

§参数
  • position_size_config - 位置和尺寸的配置
  • ctx - 用于可用空间计算的egui上下文
§返回值

返回根据配置计算出的 [位置, 尺寸]

Source

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)

Source

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)

Source

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)

Source

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.

此方法维护帧时间的滚动窗口并计算帧率等性能指标。

Source

pub fn current_fps(&self) -> f32

Update the frame rate.

更新帧数。

This method is used to obtain the number of program frames and conduct analysis.

此方法用于获取程序帧数并进行分析。

§Returns

Return the number of frames.

§返回值

返回帧数。

Source

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)

Source

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)

Source

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.

此方法更新总运行时间和当前页面运行时间。

Source

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 resource
  • value - The new value to set (use None to clear)
§Returns

Returns Ok(()) on success, or Err(RustConstructorError) if the resource cannot be found.

§参数
  • name - 变量资源的名称
  • value - 要设置的新值(使用 None 来清除)
§返回值

成功时返回 Ok(()),如果资源无法找到则返回 Err(RustConstructorError)

Source

pub fn get_variable<T: Debug + Clone + 'static>( &self, name: &str, ) -> Result<Option<T>, RustConstructorError>

Take the variable out of the list.

从列表中取出变量。

§Arguments
  • name - The name of the variable resource
§Returns

Returns Ok(Option<T>) on success, or Err(RustConstructorError) if the resource cannot be found.

§参数
  • name - 变量资源的名称
§返回值

成功时返回 Ok(Option<T>),如果资源无法找到则返回 Err(RustConstructorError)

Source

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 resource
  • enable - The new enable status
§Returns

Returns Ok(()) on success, or Err(RustConstructorError) if the resource cannot be found.

§参数
  • name - 开关资源的名称
  • enable - 新的启用状态
§返回值

成功时返回 Ok(()),如果资源无法找到则返回 Err(RustConstructorError)

Source

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§

Source§

impl Debug for App

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for App

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more