Method
set_codec
(
&mut self,
protocol: ProtocolName,
codec: BoxedCodec,
)
Source from the content-addressed store, hash-verified
| 68 | } |
| 69 | } |
| 70 | pub fn set_codec( |
| 71 | &mut self, |
| 72 | protocol: ProtocolName, |
| 73 | codec: BoxedCodec, |
| 74 | ) -> anyhow::Result<(), CodecError> { |
| 75 | if let true = self.registry.contains_key(protocol) { |
| 76 | return Err(CodecError::RegistryExistsProtocol(protocol)); |
| 77 | } else { |
| 78 | self.registry.insert(protocol, codec); |
| 79 | } |
| 80 | Ok(()) |
| 81 | } |
| 82 | |
| 83 | pub fn is_registered(&self, protocol: ProtocolName) -> bool { |
| 84 | self.registry.contains_key(protocol) |