pub enum BindMode {
Local,
Tailscale,
Explicit(String),
}Expand description
How the server should bind its listeners.
Why: Captures the three meaningful bind modes so resolve_bind_addrs can
return the right SocketAddr list for each without tangled string parsing.
What: Three variants — local-only (default), tailscale (dual listener), or
explicit (whatever the --http flag / TRUSTY_CONSOLE_BIND env var says).
Test: Constructed by BindMode::from_env_and_flags; exercised below.
Variants§
Local
Bind only 127.0.0.1:<port> — default.
Tailscale
Bind 127.0.0.1:<port> AND the detected Tailscale IPv4 <ts-ip>:<port>.
Explicit(String)
Bind the explicit address string (e.g. 0.0.0.0:7788 or 127.0.0.1:9000).
Implementations§
Source§impl BindMode
impl BindMode
Sourcepub fn from_env_and_flags(
explicit_http: &str,
default_http: &str,
tailscale_flag: bool,
) -> Self
pub fn from_env_and_flags( explicit_http: &str, default_http: &str, tailscale_flag: bool, ) -> Self
Determine the bind mode from the env var and CLI flags.
Why: Encodes the precedence rule — explicit --http wins, then
TRUSTY_CONSOLE_BIND, then --tailscale, then local default — in one
place so callers never need to re-implement it.
What: Reads TRUSTY_CONSOLE_BIND from the process environment and
delegates to from_flags_and_bind_env; see that function for full
precedence rules.
Test: test_bind_mode_* tests call from_flags_and_bind_env directly
with injected values to avoid parallel-test env-var races.
Sourcepub fn from_flags_and_bind_env(
explicit_http: &str,
default_http: &str,
tailscale_flag: bool,
bind_env: Option<&str>,
) -> Self
pub fn from_flags_and_bind_env( explicit_http: &str, default_http: &str, tailscale_flag: bool, bind_env: Option<&str>, ) -> Self
Pure, deterministic core of bind-mode resolution (no env reads).
Why: Separating the env read from the logic makes this function fully
testable without process-global env mutation — important because tests
run in parallel threads and set_var/remove_var races cause flakiness.
What: Applies a four-level precedence rule — --http override > env
"tailscale" > env non-empty addr > --tailscale flag > local default.
Test: test_bind_mode_* below call this function directly.
Trait Implementations§
impl Eq for BindMode
impl StructuralPartialEq for BindMode
Auto Trait Implementations§
impl Freeze for BindMode
impl RefUnwindSafe for BindMode
impl Send for BindMode
impl Sync for BindMode
impl Unpin for BindMode
impl UnsafeUnpin for BindMode
impl UnwindSafe for BindMode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more