llm_tools/debug/
file_data.rs

1
2use super::*;
3use openai_api_rs::v1::file::FileData;
4
5// Assuming the `format_tools` module and `field!` macro are defined elsewhere
6
7/// A wrapper for `FileData` to make pretty print.
8#[ derive( Debug ) ]
9pub struct FileDataWrap( pub FileData );
10
11/// Manually implemented `Clone`, as `FileData` does not implement it.
12impl Clone for FileDataWrap
13{
14  fn clone( &self ) -> Self
15  {
16    FileDataWrap( FileData
17    {
18      id : self.0.id.clone(),
19      object : self.0.object.clone(),
20      bytes : self.0.bytes,
21      created_at : self.0.created_at,
22      filename : self.0.filename.clone(),
23      purpose : self.0.purpose.clone(),
24    } )
25  }
26}
27
28impl TableWithFields for FileDataWrap {}
29impl Fields< &'_ str, Option< Cow< '_, str > > >
30for FileDataWrap
31{
32  type Key<'k> = &'k str;
33  type Val< 'v > = Option< Cow< 'v, str > >;
34
35  fn fields( &self ) -> impl format_tools::IteratorTrait< Item = ( &'_ str, Option< Cow< '_, str > > ) >
36  {
37    use format_tools::ref_or_display_or_debug_multiline::field;
38    let mut dst = Vec::new();
39
40    // Use the field! macro for direct field references
41    dst.push( field!( &self.0.id ) );
42    dst.push( field!( &self.0.object ) );
43    dst.push( ( "bytes", Some( Cow::Owned( self.0.bytes.to_string() ) ) ) );
44    dst.push( ( "created_at", Some( Cow::Owned( self.0.created_at.to_string() ) ) ) );
45    dst.push( field!( &self.0.filename ) );
46    dst.push( field!( &self.0.purpose ) );
47
48    dst.into_iter()
49  }
50}