pub struct HostContract {
pub csi_bind: SocketAddr,
pub sensor_url: Option<SocketAddr>,
pub token: SecretString,
pub ingest_upstream: Option<SocketAddr>,
pub ingest_url: Option<String>,
pub expose_token: bool,
}Expand description
Host contract for one instance.
Fields§
§csi_bind: SocketAddrUDP bind the cog listens on for the sensor feed.
sensor_url: Option<SocketAddr>HTTP sensor fallback address (host:port), if any.
token: SecretStringPer-instance token.
ingest_upstream: Option<SocketAddr>The node’s ingest bridge as the instance’s network sees it. A cog
always posts to its own 127.0.0.1:80; container adapters relay
that port here (super::container_relay). None means the cog’s
loopback already reaches the bridge (native, network=host).
ingest_url: Option<String>Ingest bridge URL injected as ENV_INGEST_URL, if any.
expose_token: boolFalse: the instance gets no ENV_TOKEN (and no ingest URL). Set
when the node’s ingest bridge is down, so a cog never carries a
credential for a bridge that is not there.
Implementations§
Source§impl HostContract
impl HostContract
Sourcepub fn new(csi_bind: SocketAddr) -> Self
pub fn new(csi_bind: SocketAddr) -> Self
Contract binding the feed on csi_bind, with a fresh random token.
Sourcepub fn default_feed() -> Self
pub fn default_feed() -> Self
Default: feed on 0.0.0.0:5006.
Sourcepub fn with_sensor(self, addr: SocketAddr) -> Self
pub fn with_sensor(self, addr: SocketAddr) -> Self
Builder: HTTP sensor fallback.
Sourcepub fn with_ingest_upstream(self, addr: SocketAddr) -> Self
pub fn with_ingest_upstream(self, addr: SocketAddr) -> Self
Builder: ingest bridge address as seen from inside the instance.
Sourcepub fn with_ingest_url(self, url: impl Into<String>) -> Self
pub fn with_ingest_url(self, url: impl Into<String>) -> Self
Builder: bridge URL handed to the cog as ENV_INGEST_URL.
Sourcepub fn without_ingest(self) -> Self
pub fn without_ingest(self) -> Self
Builder: hand the instance no token and no ingest URL.
Sourcepub fn fresh_token() -> SecretString
pub fn fresh_token() -> SecretString
32 random bytes, lower-case hex.
Sourcepub fn token_hash(&self) -> String
pub fn token_hash(&self) -> String
Short BLAKE3 fingerprint of the token, safe for chain payloads.
Sourcepub fn validate(&self) -> Result<(), RuntimeError>
pub fn validate(&self) -> Result<(), RuntimeError>
Validate before use.
Trait Implementations§
Source§impl Clone for HostContract
impl Clone for HostContract
Auto Trait Implementations§
impl Freeze for HostContract
impl RefUnwindSafe for HostContract
impl Send for HostContract
impl Sync for HostContract
impl Unpin for HostContract
impl UnsafeUnpin for HostContract
impl UnwindSafe for HostContract
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,
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