1// Copyright 2022 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
45use crate::prelude_internal::*;
67/// This structure represents DNS-SD server counters.
8///
9/// Functional equivalent of [`otsys::otDnssdCounters`](crate::otsys::otDnssdCounters).
10#[derive(Debug, Default, Clone)]
11#[repr(transparent)]
12pub struct DnssdCounters(pub otDnssdCounters);
1314impl_ot_castable!(DnssdCounters, otDnssdCounters);
1516impl DnssdCounters {
17/// The number of successful responses.
18pub fn success_response(&self) -> u32 {
19self.0.mSuccessResponse
20 }
2122/// The number of server failure responses.
23pub fn server_failure_response(&self) -> u32 {
24self.0.mServerFailureResponse
25 }
2627/// The number of format error responses.
28pub fn format_error_response(&self) -> u32 {
29self.0.mFormatErrorResponse
30 }
3132/// The number of name error responses.
33pub fn name_error_response(&self) -> u32 {
34self.0.mNameErrorResponse
35 }
3637/// The number of 'not implemented' responses.
38pub fn not_implemented_response(&self) -> u32 {
39self.0.mNotImplementedResponse
40 }
4142/// The number of other responses.
43pub fn other_response(&self) -> u32 {
44self.0.mOtherResponse
45 }
4647/// The number of queries completely resolved by the local SRP server.
48pub fn resolved_by_srp(&self) -> u32 {
49self.0.mResolvedBySrp
50 }
5152/// Represents the count of queries, responses, failures handled by upstream DNS server
53pub fn upstream_dns_counters(&self) -> UpstreamDnsCounters {
54self.0.mUpstreamDnsCounters.into()
55 }
56}
5758#[derive(Debug, Default, Clone)]
59#[repr(transparent)]
60/// Represents the count of queries, responses, failures handled by upstream DNS server
61///
62/// Functional equivalent of [`otsys::otUpstreamDnsCounters`](crate::otsys::otUpstreamDnsCounters).
63pub struct UpstreamDnsCounters(pub otUpstreamDnsCounters);
6465impl_ot_castable!(UpstreamDnsCounters, otUpstreamDnsCounters);
6667impl UpstreamDnsCounters {
68/// The number of queries forwarded
69pub fn queries(&self) -> u32 {
70self.0.mQueries
71 }
7273/// The number of responses forwarded
74pub fn responses(&self) -> u32 {
75self.0.mResponses
76 }
7778/// The number of upstream DNS failures
79pub fn failures(&self) -> u32 {
80self.0.mFailures
81 }
82}