返回顶部
返回首页 会员充值 我的足迹 返回上一页

陈研-RustConfChina2023.pdf

2023-06-30
文档编号:132031
文档页数:35
文档大小:1.35MB
下载积分:VIP专享
文档格式:PDF

1、第三届中国Rust开发者大会Candid:the interface description language of the Internet Computer smart contractsYan ChenDFINITY FoundationRust China Conf 2023 How DFINITY uses procedure macro to extend RustOverviewOverview Macro system is a hidden gem in Rust.We share our experience in safely extending Rust languag

2、es without modifying the compiler.Running example:Candid,a strongly typed serialization library Extended language features:Backward compatible API upgrades with subtyping Type reflection Structural typingMotivationMotivation How to maintain interoperability between microservices?MotivationMotivation

3、 How to maintain interoperability between microservices?UpgradeMotivationMotivation How to maintain interoperability between microservices?APIs are allowed to evolve without breaking existing client Wire format contains type information Decoder knows two types:wire type,and expected typeServing API

4、v2Client only knows API v1Send v1 dataDecode v1 as v2Send v2 resultDecode v2 as v1MotivationMotivation How to maintain interoperability between microservices?APIs are allowed to evolve without breaking existing client Wire format contains type information Decoder knows two types:wire type,and expect

5、ed typeServing API v2Client only knows API v1Send v1 dataDecode v1 as v2Send v2 resultDecode v2 as v1ContravarianceCovarianceSubtyping and safe upgradesSubtyping and safe upgrades Outbound data(provided by service)can upgrade to more specific data Inbound data(required by service)can upgrade to more

6、 general data Orientation is inverted for higher order functionsv3v2v1v1v2v3f :Send(record age=42:nat8)Send(record name=”Admin”;age=42:nat8)ExampleExampletype Profile=record name:text;service:getProfile:(nat)-(Profile);API v1type Profile=record name:text;age:nat8;service:getProfile:(nat)-(Profile);A

陈研-RustConfChina2023.pdf_第1页
陈研-RustConfChina2023.pdf_第2页
陈研-RustConfChina2023.pdf_第3页
陈研-RustConfChina2023.pdf_第4页
陈研-RustConfChina2023.pdf_第5页

点击查看更多