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: common.rs
    path of file: ./repos/ockam/examples/rust/mitm_node/src/tcp_interceptor/transport
    
    the code of the file until where you have to start completion: use ockam_core::compat::net::{SocketAddr, ToSocketAddrs};
use ockam_core::Result;
use ockam_transport_core::TransportError;

/// Resolve the given peer to a [`SocketAddr`](s
    
pub(super) fn resolve_peer(peer: String) -> Result<SocketAddr> {
    // Try to parse as SocketAddr
    if let Ok(p) = parse_socket_addr(&peer) {
        return Ok(p);
    }

    // Try to resolve hostname
    if let Ok(mut iter) = peer.to_socket_addrs() {
        // Prefer ip4
        if let Some(p) = iter.find(|x| x.is_ipv4()) {
            return Ok(p);
        }
        if let Some(p) = iter.find(|x| x.is_ipv6()) {
            return Ok(p);
        }
    }

    // Nothing worked, return an error
    Err(TransportError::InvalidAddress)?
}