mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	 f64b522154
			
		
	
	f64b522154
	
	
	
		
			
			Co-authored-by: James Motherwell <motherwell.james@student.greenriver.edu> Co-authored-by: James M <122129564+JamesM25@users.noreply.github.com>
		
			
				
	
	
		
			27 lines
		
	
	
		
			538 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			538 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| use std::string::String;
 | |
| 
 | |
| use serde::Deserialize;
 | |
| use toml::Value;
 | |
| 
 | |
| #[derive(Deserialize)]
 | |
| pub struct InputData {
 | |
|     username: String,
 | |
|     password: String,
 | |
|     dbname: String,
 | |
|     host: String,
 | |
|     port: u16,
 | |
| }
 | |
| 
 | |
| impl InputData {
 | |
|     pub fn read(db_table: &Value) -> Result<Self, toml::de::Error> {
 | |
|         db_table.clone().try_into()
 | |
|     }
 | |
| 
 | |
|     pub fn postgres_url(&self) -> String {
 | |
|         format!(
 | |
|             "postgres://{}:{}@{}:{}/{}",
 | |
|             self.username, self.password, self.host, self.port, self.dbname
 | |
|         )
 | |
|     }
 | |
| }
 |