base impls for what weapontype needs
This commit is contained in:
		
							parent
							
								
									0d132642b1
								
							
						
					
					
						commit
						70584a4d01
					
				| @ -1,3 +1,4 @@ | ||||
| use std::convert::{TryFrom, Into}; | ||||
| 
 | ||||
| use std::io::{Read, Seek}; | ||||
| use crate::{PSOPacketData, PacketParseError}; | ||||
| @ -63,6 +64,9 @@ pub enum WeaponSpecial { | ||||
|     Demons, | ||||
| } | ||||
| 
 | ||||
| pub enum WeaponTypeError { | ||||
|     UnknownWeapon(String) | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug, Copy, Clone)] | ||||
| pub enum WeaponType { | ||||
| @ -81,6 +85,27 @@ impl WeaponType { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl TryFrom<&str> for WeaponType { | ||||
|     type Error = WeaponTypeError; | ||||
|     fn try_from(value: &str) -> Result<WeaponType, WeaponTypeError> { | ||||
|         match value { | ||||
|             "Saber" => Ok(WeaponType::Saber), | ||||
|             "Handgun" => Ok(WeaponType::Handgun), | ||||
|             "Cane" => Ok(WeaponType::Cane), | ||||
|             _ => Err(WeaponTypeError::UnknownWeapon(value.to_string())) | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl Into<String> for WeaponType { | ||||
|     fn into(self) -> String { | ||||
|         match self { | ||||
|             WeaponType::Saber => "Saber", | ||||
|             WeaponType::Handgun => "Handgun", | ||||
|             WeaponType::Cane => "Cane", | ||||
|         }.to_string() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| #[derive(Debug, Copy, Clone)] | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user