hotpatch:在Rust中运行时更改函数定义

  • p3_856840
    了解作者
  • 35.9KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-14 20:13
    上传日期
该项目的状态 目前正在等待。 最近在这里采取了一些措施,RFC似乎即将合并。 考虑到我无论如何都在忙着上学,所以我会一直坚持下去,直到每天晚上都有内在的特质。 热补丁 此板条箱主要用于以极其简单的方式从共享库文件中加载新功能定义。 主要特征: 线程安全 输入安全 适用于任何签名的功能 知道命名空间 每晚需求 这个板条箱只在每晚进行。 它使用的功能列表如下: unboxed_closures fn_traits const_fn const_fn_fn_ptr_basics proc_macro_diagnostic 以上大多数功能对功能至关重要。 因此,该板条箱将仅在每晚完成以上操作之前保持每晚状态。 简短的例子 下面显示了此板条箱的使用方式: // main.rs use hotpatch :: * ; #[patchable] fn foo () { } fn ma
hotpatch-master.zip
内容介绍
### State of this project Currently waiting for [inherent traits](https://github.com/rust-lang/rfcs/pull/2375). There has been some action here recently, and the RFC looks like it's going to be merged soon. Given that I'm busy with school anyway, I'll be holding off on continuing development until inherent traits are in nightly. # hotpatch [![crates.io](https://img.shields.io/crates/v/hotpatch.svg)](https://crates.io/crates/hotpatch) [![docs.rs](https://docs.rs/hotpatch/badge.svg)](https://docs.rs/hotpatch) This crate is primarily used to load new function definitions from shared object files in an exceedingly easy way. Key features: - Thread safe - Type safe - Works for functions of any signature - Namespace aware ## Nightly Requirement This crate is nightly only. A list of features it uses are as follows: - `unboxed_closures` - `fn_traits` - `const_fn` - `const_fn_fn_ptr_basics` - `proc_macro_diagnostic` Most of the above features are critical to function. As such, this crate will remain nightly only until more of the above are finished. ## Short Example The following shows how dead-simple this crate is to use: ```rust // main.rs use hotpatch::*; #[patchable] fn foo() { } fn main() -> Result<(), Box<dyn std::error::Error>> { foo(); // does nothing foo.hotpatch_lib("libsomething.so")?; foo(); // does something totally different! foo.hotpatch_fn(|| println!("Dynamic!"))?; foo(); // even more modification! Ok(()) } ``` ## Warning Don't hotpatch the function you're currently in, or any of its parents. Because `hotpatch` doesn't allow multiple function definitions to be in affect at the same time, this will cause a deadlock. It is possible to do this with the `force` functions, however they are `unsafe`, as in a multithreaded enironment this could cause multiple function definitions to be in effect at once. ## Docs For more information, see the [docs](https://docs.rs/hotpatch). ## TODO This crate is still has a long way to go before being "finished". Below are some items left to do. Submit an issue or PR to this section for feature requests! - `no_std` and use features to give the widest possible functionality - probably will need to move back to `lazy_static` - wasm support - methods (in progress) - `#[patchable] ||()` to generate from a closure (is this even possible?) - lower compile times - include only necessary features for sub-dependencies
评论
    相关推荐
    • Rust
      Rust
    • rust
      安装rustup工具链: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    • rust-cityhash
      锈城 CityHash是一系列非加密哈希函数,旨在用于字符串的快速哈希。 Cityhash使用Austin Appleby的MurmurHash的想法。 有关CityHash的更多信息,请参见 这是Google的CityHash版本1.1.1移植到纯Rust的端口
    • Rust
      Rust
    • rust
      代码空间Rust Starter 该项目是供开发人员在Codespaces中使用的通用入门,它包括基本的系统工具和扩展。 包含什么 这是一个基本环境,应该准备好对其进行扩展,以构建Rust的日常开发环境。 它带有以下软件选择: ...
    • rust-zmq:Rust zeromq绑定
      Rust ZeroMQ绑定。 关于 zmq板条箱为项目中的libzmq库提供了绑定。 zmq公开的API应该是安全的(通常在Rust的意义上),但是它紧跟C API,因此不是很惯用。 同样,在“草稿”状态下对libzmq API的支持也被视为该板条...
    • rust-enforce
      Rust 中的流体断言 例子 使用来测试语法 describe ! vec { describe ! push { before_each { let mut v = vec! [1u, 2 , 3 ]; } it "should increase the length by 1" { let old = v. len (); v. push (4u);...
    • rust-learning
      我的Rust学习库 基于Traversy Media的Brad的这段视频 任务列表 在Rust中打印 Rust中的变量 Rust的类型 锈中的弦 Rust中的元组 Rust中的数组 [] Rust中的载体
    • Rust的LibYAML绑定-Rust开发
      用于Rust依赖项LibYAML 0.1.4或更高版本的libyaml-rust LibYAML绑定稳定Rust(2015/2018版)用法从内存extern crate yaml解析; 用于Rust依赖项LibYAML 0.1.4或更高版本的libyaml-rust LibYAML绑定稳定Rust(2015/...
    • rust
      rust