Skip to main content

AssessmentTransport

Struct AssessmentTransport 

Source
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

Source

pub fn new(coordinator: Arc<MeshCoordinator>) -> Self

Create a new transport wrapping the given coordinator.

Source

pub fn coordinator(&self) -> &MeshCoordinator

Return a reference to the inner coordinator.

Source

pub fn coordinator_arc(&self) -> Arc<MeshCoordinator> ⓘ

Shared coordinator handle (for status RPC / service wiring).

Source

pub fn publish_report(&self, report: AssessmentReport)

Cache the latest local report (enables RequestReport responses + ticks).

Source

pub fn latest_report(&self) -> Option<AssessmentReport>

Snapshot of the cached latest report.

Source

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).

Source

pub fn build_broadcast_frame( &self, report: &AssessmentReport, ) -> KernelResult<Vec<u8>>

Build a ReportAvailable broadcast frame.

Source

pub fn build_diff_frame( &self, report: &AssessmentReport, diff: &AssessmentDiff, ) -> KernelResult<Vec<u8>>

Build a FindingDiff frame that carries only changed findings.

Source

pub fn build_request_frame(&self) -> KernelResult<Vec<u8>>

Build a RequestReport frame addressed to a peer.

Source

pub fn build_full_report_frame( &self, report: &AssessmentReport, ) -> KernelResult<Vec<u8>>

Build a FullReport response frame.

Source

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.

Source

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).

Source

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”.

Source

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.

Source

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.

Source

pub fn peer_states(&self) -> Vec<PeerAssessmentState>

Return a snapshot of all known peer assessment states.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more