pub struct Viewtype {
pub name: String,
pub c_type: String,
pub nullable: bool,
pub size_param: Option<String>,
}Expand description
An ATS2 viewtype representing a linear type wrapper around a C type.
In ATS2, viewtypes (also called linear types) combine a view (memory layout
proof) with a type. A Viewtype describes the ATS2 type that wraps a C
pointer to enforce ownership discipline at compile time.
For example, wrapping FILE* produces a viewtype like:
viewtypedef FILE_ptr = [l:addr] (FILE @ l | ptr l)Fields§
§name: StringThe ATS2 viewtype name (e.g., “FILE_vt”, “buffer_vt”).
c_type: StringThe underlying C type being wrapped (e.g., “FILE*”, “char*”).
nullable: boolWhether this viewtype is nullable (Option-like in ATS2). Nullable viewtypes generate additional null-check proof obligations.
size_param: Option<String>Optional size constraint for buffer types.
When set, generates dependent type annotations: {n:nat} buffer_vt(n).
Implementations§
Source§impl Viewtype
impl Viewtype
Sourcepub fn new(name: &str, c_type: &str) -> Self
pub fn new(name: &str, c_type: &str) -> Self
Creates a new non-nullable viewtype wrapping the given C type.
Sourcepub fn nullable(name: &str, c_type: &str) -> Self
pub fn nullable(name: &str, c_type: &str) -> Self
Creates a nullable viewtype (for functions that may return NULL).
Sourcepub fn sized(name: &str, c_type: &str, size_param: &str) -> Self
pub fn sized(name: &str, c_type: &str, size_param: &str) -> Self
Creates a sized viewtype with a dependent type parameter.
Sourcepub fn to_ats2_definition(&self) -> String
pub fn to_ats2_definition(&self) -> String
Generates the ATS2 viewtype definition string.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Viewtype
impl<'de> Deserialize<'de> for Viewtype
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Viewtype
impl StructuralPartialEq for Viewtype
Auto Trait Implementations§
impl Freeze for Viewtype
impl RefUnwindSafe for Viewtype
impl Send for Viewtype
impl Sync for Viewtype
impl Unpin for Viewtype
impl UnsafeUnpin for Viewtype
impl UnwindSafe for Viewtype
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.