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: icmpv4_packet.rs
    path of file: ./repos/CaptfEncoder/CaptfEncoder-V3/misc/src/net/internal/packets
    
    the code of the file until where you have to start completion: use std::net::IpAddr;

use super::super::pnet_packet::icmp::echo_reply::Ec
    
pub fn decode_echo_reply(addr: IpAddr, buf: &[u8]) -> Result<EchoReply> {
    let ipv4_packet =
        Ipv4Packet::new(buf).ok_or_else(|| anyhow!("expected an Ipv4Packet"))?;

    let payload = ipv4_packet.payload();
    let icmp_packet =
        IcmpPacket::new(payload).ok_or_else(|| anyhow!("expected an Icmpv4Packet payload"))?;
    let typ = icmp_packet.get_icmp_type();
    if typ != IcmpTypes::EchoReply {
        return Err(super::Error::NotEchoReply(typ).into());
    }

    let echo_reply_packet = EchoReplyPacket::new(payload).unwrap();
    Ok(EchoReply {
        ttl: Some(ipv4_packet.get_ttl()),
        source: addr,
        seq: echo_reply_packet.get_sequence_number(),
        ident: echo_reply_packet.get_identifier(),
        size: echo_reply_packet.packet().len(),
    })
}