Skip to content

Commit f684b81

Browse files
committed
Initial commit
0 parents  commit f684b81

File tree

7 files changed

+503
-0
lines changed

7 files changed

+503
-0
lines changed

.github/workflows/rust.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Build
20+
run: cargo build --verbose
21+
- name: Run tests
22+
run: cargo test --tests --verbose
23+
- name: Run doctests
24+
run: cargo test --doc --verbose

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/target
2+
/Cargo.lock
3+
/.idea

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5+
6+
## [0.1.0] - 2023-07-07
7+
8+
### Internal
9+
10+
- 🎉 Initial release.
11+
12+
[0.1.0]: https://github.com/sunsided/query-string-builder/releases/tag/0.1.0

Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "query-string-builder"
3+
description = "A query string builder for percent encoding key-value pairs"
4+
version = "0.1.0"
5+
edition = "2021"
6+
repository = "https://github.com/sunsided/query-string-builder"
7+
keywords = ["url", "query-string", "query-argument"]
8+
categories = ["web-programming::http-client"]
9+
readme = "README.md"
10+
license-file = "LICENSE.md"
11+
12+
[dependencies]
13+
percent-encoding = "2.3.0"

LICENSE.md

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
# European Union Public License v. 1.2
2+
3+
> EUPL © the European Union 2007, 2016
4+
5+
This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined
6+
below) which is provided under the terms of this Licence. Any use of the Work,
7+
other than as authorised under this Licence is prohibited (to the extent such
8+
use is covered by a right of the copyright holder of the Work).
9+
10+
The Work is provided under the terms of this Licence when the Licensor (as
11+
defined below) has placed the following notice immediately following the
12+
copyright notice for the Work:
13+
14+
> Licensed under the EUPL
15+
16+
or has expressed by any other means his willingness to license under the EUPL.
17+
18+
## 1. Definitions
19+
20+
In this Licence, the following terms have the following meaning:
21+
22+
- ‘The Licence’: this Licence.
23+
24+
- ‘The Original Work’: the work or software distributed or communicated by the
25+
Licensor under this Licence, available as Source Code and also as Executable
26+
Code as the case may be.
27+
28+
- ‘Derivative Works’: the works or software that could be created by the
29+
Licensee, based upon the Original Work or modifications thereof. This Licence
30+
does not define the extent of modification or dependence on the Original Work
31+
required in order to classify a work as a Derivative Work; this extent is
32+
determined by copyright law applicable in the country mentioned in Article 15.
33+
34+
- ‘The Work’: the Original Work or its Derivative Works.
35+
36+
- ‘The Source Code’: the human-readable form of the Work which is the most
37+
convenient for people to study and modify.
38+
39+
- ‘The Executable Code’: any code which has generally been compiled and which is
40+
meant to be interpreted by a computer as a program.
41+
42+
- ‘The Licensor’: the natural or legal person that distributes or communicates
43+
the Work under the Licence.
44+
45+
- ‘Contributor(s)’: any natural or legal person who modifies the Work under the
46+
Licence, or otherwise contributes to the creation of a Derivative Work.
47+
48+
- ‘The Licensee’ or ‘You’: any natural or legal person who makes any usage of
49+
the Work under the terms of the Licence.
50+
51+
- ‘Distribution’ or ‘Communication’: any act of selling, giving, lending,
52+
renting, distributing, communicating, transmitting, or otherwise making
53+
available, online or offline, copies of the Work or providing access to its
54+
essential functionalities at the disposal of any other natural or legal
55+
person.
56+
57+
## 2. Scope of the rights granted by the Licence
58+
59+
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
60+
sublicensable licence to do the following, for the duration of copyright vested
61+
in the Original Work:
62+
63+
- use the Work in any circumstance and for all usage,
64+
- reproduce the Work,
65+
- modify the Work, and make Derivative Works based upon the Work,
66+
- communicate to the public, including the right to make available or display
67+
the Work or copies thereof to the public and perform publicly, as the case may
68+
be, the Work,
69+
- distribute the Work or copies thereof,
70+
- lend and rent the Work or copies thereof,
71+
- sublicense rights in the Work or copies thereof.
72+
73+
Those rights can be exercised on any media, supports and formats, whether now
74+
known or later invented, as far as the applicable law permits so.
75+
76+
In the countries where moral rights apply, the Licensor waives his right to
77+
exercise his moral right to the extent allowed by law in order to make effective
78+
the licence of the economic rights here above listed.
79+
80+
The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
81+
any patents held by the Licensor, to the extent necessary to make use of the
82+
rights granted on the Work under this Licence.
83+
84+
## 3. Communication of the Source Code
85+
86+
The Licensor may provide the Work either in its Source Code form, or as
87+
Executable Code. If the Work is provided as Executable Code, the Licensor
88+
provides in addition a machine-readable copy of the Source Code of the Work
89+
along with each copy of the Work that the Licensor distributes or indicates, in
90+
a notice following the copyright notice attached to the Work, a repository where
91+
the Source Code is easily and freely accessible for as long as the Licensor
92+
continues to distribute or communicate the Work.
93+
94+
## 4. Limitations on copyright
95+
96+
Nothing in this Licence is intended to deprive the Licensee of the benefits from
97+
any exception or limitation to the exclusive rights of the rights owners in the
98+
Work, of the exhaustion of those rights or of other applicable limitations
99+
thereto.
100+
101+
## 5. Obligations of the Licensee
102+
103+
The grant of the rights mentioned above is subject to some restrictions and
104+
obligations imposed on the Licensee. Those obligations are the following:
105+
106+
**Attribution right:** The Licensee shall keep intact all copyright, patent or
107+
trademarks notices and all notices that refer to the Licence and to the
108+
disclaimer of warranties. The Licensee must include a copy of such notices and a
109+
copy of the Licence with every copy of the Work he/she distributes or
110+
communicates. The Licensee must cause any Derivative Work to carry prominent
111+
notices stating that the Work has been modified and the date of modification.
112+
113+
**Copyleft clause:** If the Licensee distributes or communicates copies of the
114+
Original Works or Derivative Works, this Distribution or Communication will be
115+
done under the terms of this Licence or of a later version of this Licence
116+
unless the Original Work is expressly distributed only under this version of the
117+
Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee
118+
(becoming Licensor) cannot offer or impose any additional terms or conditions on
119+
the Work or Derivative Work that alter or restrict the terms of the Licence.
120+
121+
**Compatibility clause:** If the Licensee Distributes or Communicates Derivative
122+
Works or copies thereof based upon both the Work and another work licensed under
123+
a Compatible Licence, this Distribution or Communication can be done under the
124+
terms of this Compatible Licence. For the sake of this clause, ‘Compatible
125+
Licence’ refers to the licences listed in the appendix attached to this Licence.
126+
Should the Licensee's obligations under the Compatible Licence conflict with
127+
his/her obligations under this Licence, the obligations of the Compatible
128+
Licence shall prevail.
129+
130+
**Provision of Source Code:** When distributing or communicating copies of the Work,
131+
the Licensee will provide a machine-readable copy of the Source Code or indicate
132+
a repository where this Source will be easily and freely available for as long
133+
as the Licensee continues to distribute or communicate the Work.
134+
135+
**Legal Protection:** This Licence does not grant permission to use the trade names,
136+
trademarks, service marks, or names of the Licensor, except as required for
137+
reasonable and customary use in describing the origin of the Work and
138+
reproducing the content of the copyright notice.
139+
140+
## 6. Chain of Authorship
141+
142+
The original Licensor warrants that the copyright in the Original Work granted
143+
hereunder is owned by him/her or licensed to him/her and that he/she has the
144+
power and authority to grant the Licence.
145+
146+
Each Contributor warrants that the copyright in the modifications he/she brings
147+
to the Work are owned by him/her or licensed to him/her and that he/she has the
148+
power and authority to grant the Licence.
149+
150+
Each time You accept the Licence, the original Licensor and subsequent
151+
Contributors grant You a licence to their contributions to the Work, under the
152+
terms of this Licence.
153+
154+
## 7. Disclaimer of Warranty
155+
156+
The Work is a work in progress, which is continuously improved by numerous
157+
Contributors. It is not a finished work and may therefore contain defects or
158+
‘bugs’ inherent to this type of development.
159+
160+
For the above reason, the Work is provided under the Licence on an ‘as is’ basis
161+
and without warranties of any kind concerning the Work, including without
162+
limitation merchantability, fitness for a particular purpose, absence of defects
163+
or errors, accuracy, non-infringement of intellectual property rights other than
164+
copyright as stated in Article 6 of this Licence.
165+
166+
This disclaimer of warranty is an essential part of the Licence and a condition
167+
for the grant of any rights to the Work.
168+
169+
## 8. Disclaimer of Liability
170+
171+
Except in the cases of wilful misconduct or damages directly caused to natural
172+
persons, the Licensor will in no event be liable for any direct or indirect,
173+
material or moral, damages of any kind, arising out of the Licence or of the use
174+
of the Work, including without limitation, damages for loss of goodwill, work
175+
stoppage, computer failure or malfunction, loss of data or any commercial
176+
damage, even if the Licensor has been advised of the possibility of such damage.
177+
However, the Licensor will be liable under statutory product liability laws as
178+
far such laws apply to the Work.
179+
180+
## 9. Additional agreements
181+
182+
While distributing the Work, You may choose to conclude an additional agreement,
183+
defining obligations or services consistent with this Licence. However, if
184+
accepting obligations, You may act only on your own behalf and on your sole
185+
responsibility, not on behalf of the original Licensor or any other Contributor,
186+
and only if You agree to indemnify, defend, and hold each Contributor harmless
187+
for any liability incurred by, or claims asserted against such Contributor by
188+
the fact You have accepted any warranty or additional liability.
189+
190+
## 10. Acceptance of the Licence
191+
192+
The provisions of this Licence can be accepted by clicking on an icon ‘I agree’
193+
placed under the bottom of a window displaying the text of this Licence or by
194+
affirming consent in any other similar way, in accordance with the rules of
195+
applicable law. Clicking on that icon indicates your clear and irrevocable
196+
acceptance of this Licence and all of its terms and conditions.
197+
198+
Similarly, you irrevocably accept this Licence and all of its terms and
199+
conditions by exercising any rights granted to You by Article 2 of this Licence,
200+
such as the use of the Work, the creation by You of a Derivative Work or the
201+
Distribution or Communication by You of the Work or copies thereof.
202+
203+
## 11. Information to the public
204+
205+
In case of any Distribution or Communication of the Work by means of electronic
206+
communication by You (for example, by offering to download the Work from a
207+
remote location) the distribution channel or media (for example, a website) must
208+
at least provide to the public the information requested by the applicable law
209+
regarding the Licensor, the Licence and the way it may be accessible, concluded,
210+
stored and reproduced by the Licensee.
211+
212+
## 12. Termination of the Licence
213+
214+
The Licence and the rights granted hereunder will terminate automatically upon
215+
any breach by the Licensee of the terms of the Licence.
216+
217+
Such a termination will not terminate the licences of any person who has
218+
received the Work from the Licensee under the Licence, provided such persons
219+
remain in full compliance with the Licence.
220+
221+
## 13. Miscellaneous
222+
223+
Without prejudice of Article 9 above, the Licence represents the complete
224+
agreement between the Parties as to the Work.
225+
226+
If any provision of the Licence is invalid or unenforceable under applicable
227+
law, this will not affect the validity or enforceability of the Licence as a
228+
whole. Such provision will be construed or reformed so as necessary to make it
229+
valid and enforceable.
230+
231+
The European Commission may publish other linguistic versions or new versions of
232+
this Licence or updated versions of the Appendix, so far this is required and
233+
reasonable, without reducing the scope of the rights granted by the Licence. New
234+
versions of the Licence will be published with a unique version number.
235+
236+
All linguistic versions of this Licence, approved by the European Commission,
237+
have identical value. Parties can take advantage of the linguistic version of
238+
their choice.
239+
240+
## 14. Jurisdiction
241+
242+
Without prejudice to specific agreement between parties,
243+
244+
- any litigation resulting from the interpretation of this License, arising
245+
between the European Union institutions, bodies, offices or agencies, as a
246+
Licensor, and any Licensee, will be subject to the jurisdiction of the Court
247+
of Justice of the European Union, as laid down in article 272 of the Treaty on
248+
the Functioning of the European Union,
249+
250+
- any litigation arising between other parties and resulting from the
251+
interpretation of this License, will be subject to the exclusive jurisdiction
252+
of the competent court where the Licensor resides or conducts its primary
253+
business.
254+
255+
## 15. Applicable Law
256+
257+
Without prejudice to specific agreement between parties,
258+
259+
- this Licence shall be governed by the law of the European Union Member State
260+
where the Licensor has his seat, resides or has his registered office,
261+
262+
- this licence shall be governed by Belgian law if the Licensor has no seat,
263+
residence or registered office inside a European Union Member State.
264+
265+
## Appendix
266+
267+
‘Compatible Licences’ according to Article 5 EUPL are:
268+
269+
- GNU General Public License (GPL) v. 2, v. 3
270+
- GNU Affero General Public License (AGPL) v. 3
271+
- Open Software License (OSL) v. 2.1, v. 3.0
272+
- Eclipse Public License (EPL) v. 1.0
273+
- CeCILL v. 2.0, v. 2.1
274+
- Mozilla Public Licence (MPL) v. 2
275+
- GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
276+
- Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
277+
works other than software
278+
- European Union Public Licence (EUPL) v. 1.1, v. 1.2
279+
- Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
280+
Reciprocity (LiLiQ-R+).
281+
282+
The European Commission may update this Appendix to later versions of the above
283+
licences without producing a new version of the EUPL, as long as they provide
284+
the rights granted in Article 2 of this Licence and protect the covered Source
285+
Code from exclusive appropriation.
286+
287+
All other changes or additions to this Appendix require the production of a new
288+
EUPL version.

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# A query string builder for percent encoding key-value pairs
2+
3+
This is a tiny helper crate for simplifying the construction of URL query strings.
4+
The initial `?` question mark is automatically prepended.
5+
6+
## Example
7+
8+
```rust
9+
use query_string_builder::QueryString;
10+
11+
fn main() {
12+
let qs = QueryString::new()
13+
.with_value("q", "apple")
14+
.with_value("category", "fruits and vegetables");
15+
16+
assert_eq!(
17+
format!("https://example.com/{qs}"),
18+
"https://example.com/?q=apple&category=fruits%20and%20vegetables"
19+
);
20+
}
21+
```

0 commit comments

Comments
 (0)