collections/asciistr.rs
1// SPDX-License-Identifier: Apache-2.0
2//
3// Written in 2022-2026 by Dr. Maxim Orlovsky <orlovsky@ubideco.org>
4//
5// Copyright 2022-2026 Laboratories for Ubiquitous and Deterministic Computing,
6// Institute for Distributed and Cognitive Computing (InDCS), Switzerland.
7// All rights reserved.
8//
9// Copyright (C) 2022-2026 Dr Maxim Orlovsky.
10// All rights reserved.
11//
12// Licensed under the Apache License, Version 2.0 (the "License"); you may not
13// use this file except in compliance with the License. You may obtain a copy of
14// the License at <http://www.apache.org/licenses/LICENSE-2.0>
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19// License for the specific language governing permissions and limitations under
20// the License.
21
22use ascii::{AsciiChar, AsciiString};
23
24use super::{Collection, CollectionBase, CollectionBytes};
25
26impl CollectionBase for AsciiString {
27 type Item = AsciiChar;
28
29 #[inline]
30 fn item_count(&self) -> usize {
31 AsciiString::len(self)
32 }
33
34 #[inline]
35 fn push(&mut self, elem: Self::Item) {
36 AsciiString::push(self, elem)
37 }
38
39 #[inline]
40 fn clear(&mut self) {
41 AsciiString::clear(self)
42 }
43}
44
45impl CollectionBytes for AsciiString {
46 #[inline]
47 fn byte_len(&self) -> usize {
48 AsciiString::len(self)
49 }
50
51 #[inline]
52 fn item_byte_len(_item: &Self::Item) -> usize {
53 1
54 }
55}
56
57impl Collection for AsciiString {
58 #[inline]
59 fn with_capacity(capacity: usize) -> Self {
60 AsciiString::with_capacity(capacity)
61 }
62}