Skip to main content

gitea_sdk_rs/options/
package.rs

1// Copyright 2026 infinitete. All rights reserved.
2// Use of this source code is governed by a MIT-style
3// license that can be found in the LICENSE file.
4
5//! Request option types for package API endpoints.
6
7use crate::pagination::{ListOptions, QueryEncode};
8
9#[derive(Debug, Clone, Default)]
10/// Options for listing packages.
11pub struct ListPackagesOptions {
12    pub list_options: ListOptions,
13}
14
15impl QueryEncode for ListPackagesOptions {
16    fn query_encode(&self) -> String {
17        self.list_options.query_encode()
18    }
19}
20
21#[cfg(test)]
22mod tests {
23    use super::*;
24
25    #[test]
26    fn test_list_packages_options_query_encode_default() {
27        let opt = ListPackagesOptions::default();
28        assert_eq!(opt.query_encode(), "page=1");
29    }
30
31    #[test]
32    fn test_list_packages_options_query_encode_with_page_size() {
33        let opt = ListPackagesOptions {
34            list_options: ListOptions {
35                page: Some(2),
36                page_size: Some(50),
37            },
38        };
39        assert_eq!(opt.query_encode(), "page=2&limit=50");
40    }
41}