@@ -23,6 +23,16 @@ pub enum luarequire_WriteResult {
2323 Failure ,
2424}
2525
26+ /// Represents whether a configuration file is present, and if so, its syntax.
27+ #[ repr( C ) ]
28+ pub enum luarequire_ConfigStatus {
29+ Absent ,
30+ // Signals the presence of multiple configuration files
31+ Ambiguous ,
32+ PresentJson ,
33+ PresentLuau ,
34+ }
35+
2636#[ repr( C ) ]
2737pub struct luarequire_Configuration {
2838 // Returns whether requires are permitted from the given chunkname.
@@ -90,13 +100,14 @@ pub struct luarequire_Configuration {
90100 size_out : * mut usize ,
91101 ) -> luarequire_WriteResult ,
92102
93- // Returns whether a configuration file is present in the current context.
94- // If not, require-by-string will call to_parent until either a configuration file is present or
103+ // Returns whether a configuration file is present in the current context, and if so, its syntax .
104+ // If not present , require-by-string will call to_parent until either a configuration file is present or
95105 // NAVIGATE_FAILURE is returned (at root).
96- pub is_config_present : unsafe extern "C-unwind" fn ( L : * mut lua_State , ctx : * mut c_void ) -> bool ,
106+ pub get_config_status :
107+ unsafe extern "C-unwind" fn ( L : * mut lua_State , ctx : * mut c_void ) -> luarequire_ConfigStatus ,
97108
98109 // Parses the configuration file in the current context for the given alias and returns its
99- // value or WRITE_FAILURE if not found. This function is only called if is_config_present
110+ // value or WRITE_FAILURE if not found. This function is only called if get_config_status
100111 // returns true. If this function pointer is set, get_config must not be set. Opting in to this
101112 // function pointer disables parsing configuration files internally and can be used for finer
102113 // control over the configuration file parsing process.
@@ -111,9 +122,10 @@ pub struct luarequire_Configuration {
111122 ) -> luarequire_WriteResult ,
112123 > ,
113124
114- // Provides the contents of the configuration file in the current context. This function is only called
115- // if is_config_present returns true. If this function pointer is set, get_alias must not be set. Opting
116- // in to this function pointer enables parsing configuration files internally.
125+ // Provides the contents of the configuration file in the current context.
126+ // This function is only called if get_config_status does not return CONFIG_ABSENT. If this function
127+ // pointer is set, get_alias must not be set. Opting in to this function pointer enables parsing
128+ // configuration files internally.
117129 pub get_config : Option <
118130 unsafe extern "C-unwind" fn (
119131 L : * mut lua_State ,
@@ -124,6 +136,13 @@ pub struct luarequire_Configuration {
124136 ) -> luarequire_WriteResult ,
125137 > ,
126138
139+ // Returns the maximum number of milliseconds to allow for executing a given Luau-syntax configuration
140+ // file. This function is only called if get_config_status returns CONFIG_PRESENT_LUAU and can be left
141+ // undefined if support for Luau-syntax configuration files is not needed. A default value of 2000ms is
142+ // used. Negative values are treated as infinite.
143+ pub get_luau_config_timeout :
144+ Option < unsafe extern "C-unwind" fn ( L : * mut lua_State , ctx : * mut c_void ) -> c_int > ,
145+
127146 // Executes the module and places the result on the stack. Returns the number of results placed on the
128147 // stack.
129148 // Returning -1 directs the requiring thread to yield. In this case, this thread should be resumed with
0 commit comments