blob: 53b4c4f902acb70296642251a3ff4b4294cb8a04 [file]
// Part of the Crubit project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
use foo_rust_proto::{FooRequestStats, FooRequestStatsView, FooRequestView, FooResponseMut};
#[derive(Default)]
pub struct FooService {
stats: FooRequestStats,
}
impl FooService {
pub fn handle_request(&mut self, req: FooRequestView, mut rsp: FooResponseMut) -> bool {
self.stats.set_num_requests(self.stats.num_requests() + 1);
rsp.set_output(req.input());
true
}
pub fn request_stats(&self) -> FooRequestStatsView<'_> {
self.stats.as_view()
}
pub fn clone_request_stats(&self) -> FooRequestStats {
self.stats.clone()
}
pub fn update_request_stats(&mut self, updated_stats: FooRequestStats) {
self.stats = updated_stats;
}
}