pub enum Payload {
V4(Ipv4Prefix),
V6(Ipv6Prefix),
}
Expand description
All possible payload types.
Variants
V4(Ipv4Prefix)
An IPv4 prefix.
V6(Ipv6Prefix)
An IPv6 prefix.
Implementations
sourceimpl Payload
impl Payload
sourcepub fn new(version: u8, flags: u8, payload: Payload) -> Self
pub fn new(version: u8, flags: u8, payload: Payload) -> Self
Creates an payload value for the given payload.
sourcepub async fn read<Sock: AsyncRead + Unpin>(
sock: &mut Sock
) -> Result<Result<Option<Self>, EndOfData>, Error>
pub async fn read<Sock: AsyncRead + Unpin>(
sock: &mut Sock
) -> Result<Result<Option<Self>, EndOfData>, Error>
Reads a payload PDU from a reader.
The return type is a little convoluted, but hey. The method returns
Ok(Ok(Some(payload)))
if reading went well and there was a payload
PDU that we support. It returns Ok(Ok(None))
, if reading went well
and there was a payload PDU but we don’t actually support it. If
reading went well but we received an end-of-data PDU, it will be
returned as Ok(Err(eod))
. If reading fails or any other PDU is
received, an error is returned.
The reason we are just not returning unsupported payload types is that router keys are variable length and we would need to allocate data. Which is a bit wasteful if we then just proceed to throw it away.
sourcepub async fn write<A: AsyncWrite + Unpin>(&self, a: &mut A) -> Result<(), Error>
pub async fn write<A: AsyncWrite + Unpin>(&self, a: &mut A) -> Result<(), Error>
Writes the payload PDU to a writer.
sourcepub fn to_payload(&self) -> (Action, Payload)
pub fn to_payload(&self) -> (Action, Payload)
Converts the payload PDU into action and payload.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Payload
impl Send for Payload
impl Sync for Payload
impl Unpin for Payload
impl UnwindSafe for Payload
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more