@@ -202,6 +202,36 @@ impl fmt::Display for ScanError {
202202
203203impl std:: error:: Error for ScanError { }
204204
205+ /// Combined error surfaced by [`Registry::write_rust`].
206+ #[ derive( Debug ) ]
207+ pub enum WriteRustError {
208+ Resolve ( crate :: core:: resolve:: ResolveError ) ,
209+ Write ( crate :: core:: write:: WriteError ) ,
210+ }
211+
212+ impl fmt:: Display for WriteRustError {
213+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
214+ match self {
215+ WriteRustError :: Resolve ( e) => write ! ( f, "{}" , e) ,
216+ WriteRustError :: Write ( e) => write ! ( f, "{}" , e) ,
217+ }
218+ }
219+ }
220+
221+ impl std:: error:: Error for WriteRustError { }
222+
223+ impl From < crate :: core:: resolve:: ResolveError > for WriteRustError {
224+ fn from ( e : crate :: core:: resolve:: ResolveError ) -> Self {
225+ WriteRustError :: Resolve ( e)
226+ }
227+ }
228+
229+ impl From < crate :: core:: write:: WriteError > for WriteRustError {
230+ fn from ( e : crate :: core:: write:: WriteError ) -> Self {
231+ WriteRustError :: Write ( e)
232+ }
233+ }
234+
205235impl Registry {
206236 /// Construct a `Registry` by scanning a `prebindgen::Source`.
207237 pub fn from_source ( source : & Source ) -> Result < Self , ScanError > {
@@ -467,6 +497,19 @@ impl Registry {
467497 }
468498 self . type_locations . entry ( key) . or_insert_with ( || loc. clone ( ) ) ;
469499 }
500+
501+ /// One-shot: resolve every required type using `ext`, then write the
502+ /// generated Rust bindings file. The single public entry point for
503+ /// language-specific binding generation — language-agnostic because
504+ /// `ext` is any [`crate::core::prebindgen_ext::PrebindgenExt`] impl.
505+ pub fn write_rust < E : crate :: core:: prebindgen_ext:: PrebindgenExt > (
506+ & mut self ,
507+ ext : & E ,
508+ out_path : impl AsRef < std:: path:: Path > ,
509+ ) -> Result < std:: path:: PathBuf , WriteRustError > {
510+ crate :: core:: resolve:: resolve ( self , ext) ?;
511+ Ok ( crate :: core:: write:: write_rust ( self , ext, out_path) ?)
512+ }
470513}
471514
472515// ──────────────────────────────────────────────────────────────────────
0 commit comments