| 80 | } |
| 81 | |
| 82 | pub fn edit(&self, input: EditAssetOperationInput) -> ServiceResult<Asset> { |
| 83 | let mut asset = self.get(&input.asset_id)?; |
| 84 | |
| 85 | if let Some(name) = input.name { |
| 86 | asset.name = name; |
| 87 | } |
| 88 | |
| 89 | if let Some(symbol) = input.symbol { |
| 90 | asset.symbol = symbol; |
| 91 | } |
| 92 | |
| 93 | if let Some(change_metadata) = input.change_metadata { |
| 94 | asset.metadata.change(change_metadata); |
| 95 | } |
| 96 | |
| 97 | if let Some(blockchain) = input.blockchain { |
| 98 | asset.blockchain = blockchain; |
| 99 | } |
| 100 | |
| 101 | if let Some(standards) = input.standards { |
| 102 | asset.standards = standards.into_iter().collect(); |
| 103 | } |
| 104 | |
| 105 | asset.validate()?; |
| 106 | |
| 107 | self.asset_repository.insert(asset.id, asset.clone()); |
| 108 | |
| 109 | Ok(asset) |
| 110 | } |
| 111 | |
| 112 | pub fn remove(&self, input: RemoveAssetOperationInput) -> ServiceResult<Asset> { |
| 113 | let asset = self.get(&input.asset_id)?; |