\emph{Session types} have proved viable in expressing and verifying the protocols of message-passing systems. While message passing is a dominant concurrency paradigm in practice, real world software is written without session types. A limitation of existing session type libraries in mainstream languages is their restriction to linear session types, precluding application scenarios that demand sharing and thus aliasing of channel references. This paper introduces Ferrite, a shallow embedding of session types in Rust that supports both \emph{linear} and \emph{shared} sessions. The formal foundation of Ferrite constitutes the shared session type calculus $\sills$, which Ferrite encodes via a novel \emph{judgmental embedding} technique. The fulcrum of the embedding is the notion of a typing judgment that allows reasoning about shared and linear resources to type a session. Typing rules are then encoded as functions over judgments, with a valid typing derivation manifesting as a well-typed Rust program. This Rust program generated by Ferrite serves as a \emph{certificate}, ensuring that the application will proceed according to the protocol defined by the session type. The paper details the features and implementation of Ferrite and includes a case study on implementing Servo's canvas component in Ferrite.
翻译:\ emph{ 会话类型} 已证明在表达和核实信件传递系统协议方面是可行的。 虽然传递信息在实践中是一种主要的货币模式, 真正的世界软件是没有会话类型。 主流语言中现有会话类型图书馆的局限性在于它们限制于线性会话类型, 排除了要求共享并因此对频道引用进行别名的应用设想。 本文介绍Ferterit, 这是在 Rust 中浅浅浅嵌入的会话类型, 支持\ emph{ linear} 和\ emph{ 共享} 会话。 Ferrite 的正式基础构成共同的会话类型 : $\ sills $, 由 Ferrite 生成的会话类型为 Exmphertical 编码, 通过新书\ { judgregimatate} 技术。 嵌入行的轮廓判断概念是允许对共享和线性资源进行推理推理, 然后将调规则编码为对判决的函数的函数, 以及执行方式的精细 。