You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: error.rs
    path of file: ./repos/habitat/components/launcher-protocol/src
    
    the code of the file until where you have to start completion: use crate::types::NetErr;
use std::{fmt,
          result};

#[derive(Debug)]
pub enum Error {
    Deserialize(prost::DecodeError),
    NetErr(NetErr),
    ProtocolMismatch(&'static str),
    Serialize(prost::EncodeError),
}

pub type Result<T> = result::Result<T, Error>;

impl fmt::Display for Error 
    
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let msg = match *self {
            Error::Deserialize(ref e) => format!("Unable to deserialize message: {}", e),
            Error::NetErr(ref e) => format!("Net error: {}", e),
            Error::ProtocolMismatch(ref field) => {
                format!("Received an unsupported or bad protocol message. Missing field: {}",
                        field)
            }
            Error::Serialize(ref e) => format!("Unable to serialize message: {}", e),
        };
        write!(f, "{}", msg)
    }