Created
August 2, 2022 08:57
-
-
Save ilopX/f0d3893b3049a988270068c364963e7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| CvsMiner.mine("file.cvs"); | |
| TxtMiner.mine("file.txt"); | |
| } | |
| trait Miner { | |
| fn mine(&self, file_name: &str) { | |
| let file = self.open_file(file_name); | |
| let raw = self.extract_data(file); | |
| let table = self.parse_data(raw); | |
| let analysis = self.analyze_data(&table); | |
| self.send_report(analysis, table); | |
| } | |
| fn open_file(&self, file_name: &str) -> () { | |
| println!("open_file {}", file_name); | |
| } | |
| fn extract_data(&self, file: ()) -> String { | |
| println!("extract data"); | |
| "".into() | |
| } | |
| fn parse_data(&self, raw: String) -> (); | |
| fn analyze_data(&self, table: &()) -> () { | |
| println!("analyze_data"); | |
| } | |
| fn send_report(&self, analysis: (), table: ()) { | |
| println!("send_report\n"); | |
| } | |
| } | |
| struct CvsMiner; | |
| impl Miner for CvsMiner { | |
| fn parse_data(&self, raw: String) -> () { | |
| println!("mine Cvs"); | |
| } | |
| } | |
| struct TxtMiner; | |
| impl Miner for TxtMiner { | |
| fn parse_data(&self, raw: String) -> () { | |
| println!("mine Txt"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment