use tor_cell::relaycell::msg::{BeginFlags, IpVersionPreference};
#[derive(Clone, Debug, Default)]
pub struct StreamParameters {
ip_version: IpVersionPreference,
optimistic: bool,
suppress_hostname: bool,
suppress_begin_flags: bool,
}
impl StreamParameters {
pub fn new() -> Self {
Self::default()
}
pub fn suppress_begin_flags(&mut self) -> &mut Self {
self.suppress_begin_flags = true;
self
}
pub fn suppress_hostname(&mut self) -> &mut Self {
self.suppress_hostname = true;
self
}
pub fn ip_version(&mut self, preference: IpVersionPreference) -> &mut Self {
self.ip_version = preference;
self
}
pub fn optimistic(&mut self, optimistic: bool) -> &mut Self {
self.optimistic = optimistic;
self
}
pub(crate) fn is_optimistic(&self) -> bool {
self.optimistic
}
pub(crate) fn begin_flags(&self) -> BeginFlags {
if self.suppress_begin_flags {
0.into()
} else {
self.ip_version.into()
}
}
pub(crate) fn suppressing_hostname(&self) -> bool {
self.suppress_hostname
}
}