content: // generated by diplomat-tool
  // dart format off
  
  part of 'lib.g.dart';
  
  final class Foo implements ffi.Finalizable {
    final ffi.Pointer<ffi.Opaque> _ffi;
  
    // These are "used" in the sense that they keep dependencies alive
    // ignore: unused_field
    final core.List<Object> _selfEdge;
    // ignore: unused_field
    final core.List<Object> _aEdge;
  
    // This takes in a list of lifetime edges (including for &self borrows)
    // corresponding to data this may borrow from. These should be flat arrays containing
    // references to objects, and this object will hold on to them to keep them alive and
    // maintain borrow validity.
    Foo._fromFfi(this._ffi, this._selfEdge, this._aEdge) {
      if (_selfEdge.isEmpty) {
        _finalizer.attach(this, _ffi.cast());
      }
    }
  
    @_DiplomatFfiUse('Foo_destroy')
    static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_Foo_destroy));
  
    factory Foo(String x) {
      final xArena = _FinalizedArena();
      // This lifetime edge depends on lifetimes: 'a
      core.List<Object> aEdges = [xArena];
      final result = _Foo_new(x._utf8AllocIn(xArena.arena));
      return Foo._fromFfi(result, [], aEdges);
    }
  
    Bar get bar {
      // This lifetime edge depends on lifetimes: 'a
      core.List<Object> aEdges = [this];
      // This lifetime edge depends on lifetimes: 'a, 'b
      core.List<Object> bEdges = [this];
      final result = _Foo_get_bar(_ffi);
      return Bar._fromFfi(result, [], bEdges, aEdges);
    }
  
    BorrowedFieldsReturning asReturning() {
      // This lifetime edge depends on lifetimes: 'a
      core.List<Object> aEdges = [this];
      final result = _Foo_as_returning(_ffi);
      return BorrowedFieldsReturning._fromFfi(result, aEdges);
    }
  
    factory Foo.extractFromFields(BorrowedFields fields) {
      final temp = _FinalizedArena();
      // This lifetime edge depends on lifetimes: 'a
      core.List<Object> aEdges = [...fields._fieldsForLifetimeA];
      final result = _Foo_extract_from_fields(fields._toFfi(temp.arena, aAppendArray: [aEdges]));
      return Foo._fromFfi(result, [], aEdges);
    }
  
    /// Test that the extraction logic correctly pins the right fields
    factory Foo.extractFromBounds(BorrowedFieldsWithBounds bounds, String anotherString) {
      final temp = _FinalizedArena();
      final anotherStringArena = _FinalizedArena();
      // This lifetime edge depends on lifetimes: 'a, 'y, 'z
      core.List<Object> aEdges = [...bounds._fieldsForLifetimeB, ...bounds._fieldsForLifetimeC, anotherStringArena];
      final result = _Foo_extract_from_bounds(bounds._toFfi(temp.arena, bAppendArray: [aEdges], cAppendArray: [aEdges]), anotherString._utf8AllocIn(anotherStringArena.arena));
      return Foo._fromFfi(result, [], aEdges);
    }
  
  }
  
  @_DiplomatFfiUse('Foo_destroy')
  @ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>)>(isLeaf: true, symbol: 'Foo_destroy')
  // ignore: non_constant_identifier_names
  external void _Foo_destroy(ffi.Pointer<ffi.Void> self);
  
  @_DiplomatFfiUse('Foo_new')
  @ffi.Native<ffi.Pointer<ffi.Opaque> Function(_SliceUtf8)>(isLeaf: true, symbol: 'Foo_new')
  // ignore: non_constant_identifier_names
  external ffi.Pointer<ffi.Opaque> _Foo_new(_SliceUtf8 x);
  
  @_DiplomatFfiUse('Foo_get_bar')
  @ffi.Native<ffi.Pointer<ffi.Opaque> Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'Foo_get_bar')
  // ignore: non_constant_identifier_names
  external ffi.Pointer<ffi.Opaque> _Foo_get_bar(ffi.Pointer<ffi.Opaque> self);
  
  @_DiplomatFfiUse('Foo_as_returning')
  @ffi.Native<_BorrowedFieldsReturningFfi Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'Foo_as_returning')
  // ignore: non_constant_identifier_names
  external _BorrowedFieldsReturningFfi _Foo_as_returning(ffi.Pointer<ffi.Opaque> self);
  
  @_DiplomatFfiUse('Foo_extract_from_fields')
  @ffi.Native<ffi.Pointer<ffi.Opaque> Function(_BorrowedFieldsFfi)>(isLeaf: true, symbol: 'Foo_extract_from_fields')
  // ignore: non_constant_identifier_names
  external ffi.Pointer<ffi.Opaque> _Foo_extract_from_fields(_BorrowedFieldsFfi fields);
  
  @_DiplomatFfiUse('Foo_extract_from_bounds')
  @ffi.Native<ffi.Pointer<ffi.Opaque> Function(_BorrowedFieldsWithBoundsFfi, _SliceUtf8)>(isLeaf: true, symbol: 'Foo_extract_from_bounds')
  // ignore: non_constant_identifier_names
  external ffi.Pointer<ffi.Opaque> _Foo_extract_from_bounds(_BorrowedFieldsWithBoundsFfi bounds, _SliceUtf8 anotherString);
  
  // dart format on
  