use serde::{Deserialize, Serialize};
use crate::encode::ShouldCompress;
use crate::{PeerId, Session};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SessionResponse {
requested_by: PeerId,
sent_by: PeerId,
session: Session,
}
impl SessionResponse {
#[inline(always)]
pub fn into_session(self) -> Session {
self.session
}
#[cfg(feature = "__client")]
#[inline(always)]
pub fn new(
requested_by: PeerId,
sent_by: PeerId,
session: Session,
) -> Self {
Self { requested_by, sent_by, session }
}
#[inline(always)]
pub fn requested_by(&self) -> PeerId {
self.requested_by
}
#[inline(always)]
pub fn sent_by(&self) -> PeerId {
self.sent_by
}
#[inline(always)]
pub fn session(&self) -> &Session {
&self.session
}
}
impl ShouldCompress for SessionResponse {
#[inline]
fn should_compress(&self) -> bool {
true
}
}