pub struct AssessmentTransport { /* private fields */ }Expand description
Real-time assessment mesh transport.
Connects the assessment layer’s MeshCoordinator with the K6
mesh networking stack. Holds an Arc reference to the coordinator
so the same coordinator is shared with [AssessmentService].
The transport does not own any network connections itself. Instead
it produces serialized MeshFrame bytes and accepts incoming
bytes, delegating actual send/recv to the caller (typically the
[MeshRuntime] or a dedicated assessment sync loop).
Implementations§
Source§impl AssessmentTransport
impl AssessmentTransport
Sourcepub fn new(coordinator: Arc<MeshCoordinator>) -> Self
pub fn new(coordinator: Arc<MeshCoordinator>) -> Self
Create a new transport wrapping the given coordinator.
Sourcepub fn coordinator(&self) -> &MeshCoordinator
pub fn coordinator(&self) -> &MeshCoordinator
Return a reference to the inner coordinator.
Sourcepub fn coordinator_arc(&self) -> Arc<MeshCoordinator> ⓘ
pub fn coordinator_arc(&self) -> Arc<MeshCoordinator> ⓘ
Shared coordinator handle (for status RPC / service wiring).
Sourcepub fn publish_report(&self, report: AssessmentReport)
pub fn publish_report(&self, report: AssessmentReport)
Cache the latest local report (enables RequestReport responses + ticks).
Sourcepub fn latest_report(&self) -> Option<AssessmentReport>
pub fn latest_report(&self) -> Option<AssessmentReport>
Snapshot of the cached latest report.
Sourcepub fn build_gossip_frame(
&self,
report: &AssessmentReport,
) -> KernelResult<Vec<u8>>
pub fn build_gossip_frame( &self, report: &AssessmentReport, ) -> KernelResult<Vec<u8>>
Build a gossip frame from the latest assessment report.
Returns None if there is nothing to gossip (no report).
Sourcepub fn build_broadcast_frame(
&self,
report: &AssessmentReport,
) -> KernelResult<Vec<u8>>
pub fn build_broadcast_frame( &self, report: &AssessmentReport, ) -> KernelResult<Vec<u8>>
Build a ReportAvailable broadcast frame.
Sourcepub fn build_diff_frame(
&self,
report: &AssessmentReport,
diff: &AssessmentDiff,
) -> KernelResult<Vec<u8>>
pub fn build_diff_frame( &self, report: &AssessmentReport, diff: &AssessmentDiff, ) -> KernelResult<Vec<u8>>
Build a FindingDiff frame that carries only changed findings.
Sourcepub fn build_request_frame(&self) -> KernelResult<Vec<u8>>
pub fn build_request_frame(&self) -> KernelResult<Vec<u8>>
Build a RequestReport frame addressed to a peer.
Sourcepub fn build_full_report_frame(
&self,
report: &AssessmentReport,
) -> KernelResult<Vec<u8>>
pub fn build_full_report_frame( &self, report: &AssessmentReport, ) -> KernelResult<Vec<u8>>
Build a FullReport response frame.
Sourcepub fn drain_pending(&self) -> Option<Vec<u8>>
pub fn drain_pending(&self) -> Option<Vec<u8>>
Drain the pending broadcast (if any) from the coordinator and return it as encoded frame bytes ready for the wire.
Sourcepub fn try_extract_payload(data: &[u8]) -> KernelResult<Option<Vec<u8>>>
pub fn try_extract_payload(data: &[u8]) -> KernelResult<Option<Vec<u8>>>
Try to decode an AssessmentSync payload from raw peer bytes.
Accepts either a full MeshFrame::encode buffer
([4-byte len][type][payload]) or a type-prefixed buffer
([type][payload] as produced after transport length stripping).
Returns Ok(None) when the bytes are not an AssessmentSync frame
(caller should fall through to IPC envelope handling).
Sourcepub fn try_handle_raw(
&self,
data: &[u8],
) -> KernelResult<Option<Option<Vec<u8>>>>
pub fn try_handle_raw( &self, data: &[u8], ) -> KernelResult<Option<Option<Vec<u8>>>>
Handle raw peer bytes if they carry AssessmentSync; otherwise
return Ok(None) so the mesh runtime can treat them as IPC.
On AssessmentSync, returns Ok(Some(response_bytes)) when a
reply should be sent, or Ok(Some(empty)) is not used — Ok(Some(None))
isn’t valid. Convention: Ok(Some(opt_reply)) where outer Some
means “this was assessment traffic”.
Sourcepub fn handle_incoming(
&self,
frame_payload: &[u8],
) -> KernelResult<Option<Vec<u8>>>
pub fn handle_incoming( &self, frame_payload: &[u8], ) -> KernelResult<Option<Vec<u8>>>
Handle an incoming AssessmentSync frame payload.
Decodes the envelope, feeds the inner message to the coordinator,
and returns an optional response message (encoded as frame bytes)
that should be sent back to the source peer. RequestReport is
answered with a FullReport when a local report has been published.
Sourcepub fn gossip_tick(
&self,
latest_report: Option<&AssessmentReport>,
) -> Option<Vec<u8>>
pub fn gossip_tick( &self, latest_report: Option<&AssessmentReport>, ) -> Option<Vec<u8>>
Drive one gossip tick.
If the assessment service has a latest report, this builds a gossip message and returns it as encoded frame bytes for broadcast to all peers. The caller is responsible for sending the bytes to each connected peer.
Returns None if there is no report to gossip about.
Sourcepub fn peer_states(&self) -> Vec<PeerAssessmentState>
pub fn peer_states(&self) -> Vec<PeerAssessmentState>
Return a snapshot of all known peer assessment states.
Auto Trait Implementations§
impl !Freeze for AssessmentTransport
impl RefUnwindSafe for AssessmentTransport
impl Send for AssessmentTransport
impl Sync for AssessmentTransport
impl Unpin for AssessmentTransport
impl UnsafeUnpin for AssessmentTransport
impl UnwindSafe for AssessmentTransport
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> 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