1 // Copyright (C) 2023 Huawei Device Co., Ltd. 2 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // you may not use this file except in compliance with the License. 4 // You may obtain a copy of the License at 5 // 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 pub(crate) struct QosChanges { 15 pub(crate) download: Option<Vec<QosDirection>>, 16 pub(crate) upload: Option<Vec<QosDirection>>, 17 } 18 19 impl QosChanges { new() -> Self20 pub(crate) fn new() -> Self { 21 Self { 22 upload: None, 23 download: None, 24 } 25 } 26 } 27 #[derive(Debug)] 28 pub(crate) struct QosDirection { 29 uid: u64, 30 task_id: u32, 31 direction: QosLevel, 32 } 33 34 impl QosDirection { uid(&self) -> u6435 pub(crate) fn uid(&self) -> u64 { 36 self.uid 37 } 38 task_id(&self) -> u3239 pub(crate) fn task_id(&self) -> u32 { 40 self.task_id 41 } 42 direction(&self) -> QosLevel43 pub(crate) fn direction(&self) -> QosLevel { 44 self.direction 45 } 46 new(uid: u64, task_id: u32, direction: QosLevel) -> Self47 pub(crate) fn new(uid: u64, task_id: u32, direction: QosLevel) -> Self { 48 Self { 49 uid, 50 task_id, 51 direction, 52 } 53 } 54 } 55 56 // QosLevel's enum value means max speed (B/s) 57 #[derive(PartialEq, Eq, Clone, Copy, Debug)] 58 pub(crate) enum QosLevel { 59 High = 0, 60 Low = 400 * 1024, 61 Middle = 800 * 1024, 62 } 63