@@ -142,6 +142,15 @@ impl From<Type> for StructElementType {
142142 }
143143}
144144
145+ /// struct type affects the type of code the backend will generate
146+ #[ derive( Copy , Clone , Debug , PartialEq ) ]
147+ pub enum NativeStructType {
148+ /// struct members are public
149+ Public ,
150+ /// struct members are private (except C of course), and the struct is just an opaque "token"
151+ Opaque ,
152+ }
153+
145154#[ derive( Debug ) ]
146155pub struct NativeStructElement {
147156 pub name : String ,
@@ -152,6 +161,7 @@ pub struct NativeStructElement {
152161/// C-style structure definition
153162#[ derive( Debug ) ]
154163pub struct NativeStruct {
164+ pub struct_type : NativeStructType ,
155165 pub declaration : NativeStructDeclarationHandle ,
156166 pub elements : Vec < NativeStructElement > ,
157167 pub doc : Doc ,
@@ -179,6 +189,7 @@ pub type NativeStructHandle = Handle<NativeStruct>;
179189
180190pub struct NativeStructBuilder < ' a > {
181191 lib : & ' a mut LibraryBuilder ,
192+ struct_type : NativeStructType ,
182193 declaration : NativeStructDeclarationHandle ,
183194 elements : Vec < NativeStructElement > ,
184195 element_names_set : HashSet < String > ,
@@ -192,13 +203,19 @@ impl<'a> NativeStructBuilder<'a> {
192203 ) -> Self {
193204 Self {
194205 lib,
206+ struct_type : NativeStructType :: Public , // defaults to a public struct
195207 declaration,
196208 elements : Vec :: new ( ) ,
197209 element_names_set : HashSet :: new ( ) ,
198210 doc : None ,
199211 }
200212 }
201213
214+ pub fn make_opaque ( mut self ) -> Self {
215+ self . struct_type = NativeStructType :: Opaque ;
216+ self
217+ }
218+
202219 pub fn add < S : Into < String > , T : Into < StructElementType > , D : Into < Doc > > (
203220 mut self ,
204221 name : S ,
@@ -250,6 +267,7 @@ impl<'a> NativeStructBuilder<'a> {
250267 } ;
251268
252269 let handle = NativeStructHandle :: new ( NativeStruct {
270+ struct_type : self . struct_type ,
253271 declaration : self . declaration . clone ( ) ,
254272 elements : self . elements ,
255273 doc,
0 commit comments