33
44#![ allow( clippy:: result_large_err) ]
55
6- use anyhow:: bail;
76use aws_config:: meta:: region:: RegionProviderChain ;
87use aws_sdk_s3:: types:: {
98 CompressionType , CsvInput , ExpressionType , FileHeaderInfo , InputSerialization , JsonOutput ,
@@ -44,12 +43,12 @@ struct Opt {
4443
4544#[ derive( Debug , Deserialize ) ]
4645#[ serde( rename_all = "PascalCase" ) ]
47- struct Record {
48- name : String ,
49- phone_number : String ,
50- city : String ,
51- occupation : String ,
52- description : String ,
46+ pub struct Record {
47+ pub name : String ,
48+ pub phone_number : String ,
49+ pub city : String ,
50+ pub occupation : String ,
51+ pub description : String ,
5352}
5453
5554fn is_valid_json ( data : impl AsRef < str > ) -> bool {
@@ -65,7 +64,7 @@ async fn get_content(
6564 name : & str ,
6665) -> Result < ( ) , anyhow:: Error > {
6766 // To escape a single quote, use two single quotes.
68- let name = name. replace ( "'" , "''" ) ;
67+ let name = name. replace ( '\'' , "''" ) ;
6968 let person: String = format ! ( "SELECT * FROM s3object s where s.Name like '{name}%'" ) ;
7069 tracing:: info!( query = %person) ;
7170
@@ -131,11 +130,11 @@ async fn get_content(
131130/// Parse a new line &str, potentially using content from the previous line
132131fn parse_line_buffered ( buf : & mut String , line : & str ) -> Result < Option < Record > , anyhow:: Error > {
133132 if buf. is_empty ( ) && is_valid_json ( line) {
134- return Ok ( Some ( serde_json:: from_str ( line) ?) ) ;
133+ Ok ( Some ( serde_json:: from_str ( line) ?) )
135134 } else {
136135 buf. push_str ( line) ;
137136 if is_valid_json ( & buf) {
138- let result = serde_json:: from_str ( & buf) ;
137+ let result = serde_json:: from_str ( buf) ;
139138 buf. clear ( ) ;
140139 Ok ( Some ( result?) )
141140 } else {
0 commit comments