Skip to content

Commit

Permalink
doc(core): improve documentation of tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiapple852 committed Jul 1, 2024
1 parent 2de296b commit c99aeeb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/trippy-core/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ use std::time::Duration;
/// The state of a trace.
#[derive(Debug, Clone, Default)]
pub struct State {
/// The configuration for the state.
state_config: StateConfig,
/// The flow id for the current round.
round_flow_id: FlowId,
/// Tracing data per registered flow id.
/// Tracing state per registered flow id.
state: HashMap<FlowId, FlowState>,
/// Flow registry.
registry: FlowRegistry,
Expand All @@ -23,7 +24,7 @@ pub struct State {
}

impl State {
/// Create a new `Trace`.
/// Create a new `State`.
#[must_use]
pub fn new(state_config: StateConfig) -> Self {
Self {
Expand Down Expand Up @@ -98,6 +99,7 @@ impl State {
self.registry.flows()
}

/// The error message for the trace, if any.
#[must_use]
pub fn error(&self) -> Option<&str> {
self.error.as_deref()
Expand Down
24 changes: 24 additions & 0 deletions crates/trippy-core/src/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,121 +277,145 @@ impl Tracer {
self.inner.clear();
}

/// The maximum number of flows to record.
#[must_use]
pub fn max_flows(&self) -> usize {
self.inner.max_flows()
}

/// The maximum number of samples to record.
#[must_use]
pub fn max_samples(&self) -> usize {
self.inner.max_samples()
}

/// The privilege mode of the tracer.
#[must_use]
pub fn privilege_mode(&self) -> PrivilegeMode {
self.inner.privilege_mode()
}

/// The protocol of the tracer.
#[must_use]
pub fn protocol(&self) -> Protocol {
self.inner.protocol()
}

/// The interface to use for the tracer.
#[must_use]
pub fn interface(&self) -> Option<&str> {
self.inner.interface()
}

/// The source address of the tracer.
#[must_use]
pub fn source_addr(&self) -> Option<IpAddr> {
self.inner.source_addr()
}

/// The target address of the tracer.
#[must_use]
pub fn target_addr(&self) -> IpAddr {
self.inner.target_addr()
}

/// The packet size of the tracer.
#[must_use]
pub fn packet_size(&self) -> PacketSize {
self.inner.packet_size()
}

/// The payload pattern of the tracer.
#[must_use]
pub fn payload_pattern(&self) -> PayloadPattern {
self.inner.payload_pattern()
}

/// The initial sequence number of the tracer.
#[must_use]
pub fn initial_sequence(&self) -> Sequence {
self.inner.initial_sequence()
}

/// The type of service of the tracer.
#[must_use]
pub fn tos(&self) -> TypeOfService {
self.inner.tos()
}

/// The ICMP extension parse mode of the tracer.
#[must_use]
pub fn icmp_extension_parse_mode(&self) -> IcmpExtensionParseMode {
self.inner.icmp_extension_parse_mode()
}

/// The read timeout of the tracer.
#[must_use]
pub fn read_timeout(&self) -> Duration {
self.inner.read_timeout()
}

/// The TCP connect timeout of the tracer.
#[must_use]
pub fn tcp_connect_timeout(&self) -> Duration {
self.inner.tcp_connect_timeout()
}

/// The trace identifier of the tracer.
#[must_use]
pub fn trace_identifier(&self) -> TraceId {
self.inner.trace_identifier()
}

/// The maximum number of rounds of the tracer.
#[must_use]
pub fn max_rounds(&self) -> Option<MaxRounds> {
self.inner.max_rounds()
}

/// The first time-to-live value of the tracer.
#[must_use]
pub fn first_ttl(&self) -> TimeToLive {
self.inner.first_ttl()
}

/// The maximum time-to-live value of the tracer.
#[must_use]
pub fn max_ttl(&self) -> TimeToLive {
self.inner.max_ttl()
}

/// The grace duration of the tracer.
#[must_use]
pub fn grace_duration(&self) -> Duration {
self.inner.grace_duration()
}

/// The maximum number of inflight probes of the tracer.
#[must_use]
pub fn max_inflight(&self) -> MaxInflight {
self.inner.max_inflight()
}

/// The multipath strategy of the tracer.
#[must_use]
pub fn multipath_strategy(&self) -> MultipathStrategy {
self.inner.multipath_strategy()
}

/// The port direction of the tracer.
#[must_use]
pub fn port_direction(&self) -> PortDirection {
self.inner.port_direction()
}

/// The minimum round duration of the tracer.
#[must_use]
pub fn min_round_duration(&self) -> Duration {
self.inner.min_round_duration()
}

/// The maximum round duration of the tracer.
#[must_use]
pub fn max_round_duration(&self) -> Duration {
self.inner.max_round_duration()
Expand Down

0 comments on commit c99aeeb

Please sign in to comment.