src/handlers/formatters/mock_formatter.rs
Lines
100.00 %
Functions
100.00 %
Regions
100.00 %
| Line | Count | Source (jump to first uncovered line) |
|---|---|---|
| 1 | // | |
| 2 | // File Name: mock_formatter.rs | |
| 3 | // Directory: src/handlers/formatters | |
| 4 | // Project Name: flogging | |
| 5 | // | |
| 6 | // Copyright (C) 2025 Bradley Willcott | |
| 7 | // | |
| 8 | // SPDX-License-Identifier: GPL-3.0-or-later | |
| 9 | // | |
| 10 | // This library (crate) is free software: you can redistribute it and/or modify | |
| 11 | // it under the terms of the GNU General Public License as published by | |
| 12 | // the Free Software Foundation, either version 3 of the License, or | |
| 13 | // (at your option) any later version. | |
| 14 | // | |
| 15 | // This library (crate) is distributed in the hope that it will be useful, | |
| 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 | // GNU General Public License for more details. | |
| 19 | // | |
| 20 | // You should have received a copy of the GNU General Public License | |
| 21 | // along with this library (crate). If not, see <https://www.gnu.org/licenses/>. | |
| 22 | // | |
| 23 | ||
| 24 | //! | |
| 25 | //! # Mock Formatter | |
| 26 | //! | |
| 27 | ||
| 28 | use ::fmt; | |
| 29 | use crate::FormatTrait; | |
| 30 | ||
| 31 | /// | |
| 32 | /// Mock Formatter. | |
| 33 | /// | |
| 34 | /// Used as a filler. It does not have a proper format string. It is also used | |
| 35 | /// in examples for custom formatters. | |
| 36 | /// | |
| 37 | #[derive(,,,,)] | |
| 38 | pub struct MockFormatter { | |
| 39 | dt_fmt: | |
| 40 | fmt_string: | |
| 41 | } | |
| 42 | ||
| 43 | impl MockFormatter { | |
| 44 | /// | |
| 45 | /// Creates a new instance of `MockFormatter`. | |
| 46 | /// | |
| 47 | 3 | pub fn new() -> Self { |
| 48 | 3 | Self { |
| 49 | 3 | : ""to_string(), |
| 50 | 3 | : "MockFormatter"to_string(), |
| 51 | 3 | } |
| 52 | 3 | } |
| 53 | ||
| 54 | /// | |
| 55 | /// Returns the date/time format string. | |
| 56 | /// | |
| 57 | 3 | pub fn dt_fmt(&self) -> { |
| 58 | 3 | selfclone() |
| 59 | 3 | } |
| 60 | ||
| 61 | /// | |
| 62 | /// Returns the primary format string. | |
| 63 | /// | |
| 64 | 2 | pub fn fmt_string(&self) -> { |
| 65 | 2 | selfclone() |
| 66 | 2 | } |
| 67 | } | |
| 68 | ||
| 69 | impl for MockFormatter { | |
| 70 | 1 | fn default() -> Self { |
| 71 | 1 | Self::() |
| 72 | 1 | } |
| 73 | } | |
| 74 | ||
| 75 | impl ::for MockFormatter { | |
| 76 | 2 | fn fmt(&selff: &mut ::<_>) -> :: { |
| 77 | 2 | write!( "{}", selffmt_string()) |
| 78 | 2 | } |
| 79 | } | |
| 80 | ||
| 81 | impl for MockFormatter { | |
| 82 | 3 | fn format(&self_log_entry: &::) -> { |
| 83 | 3 | let _ = selfdt_fmt(); |
| 84 | 3 | "MockFormatter"to_string() |
| 85 | 3 | } |
| 86 | } |