File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,45 @@ cargo add ggemini
18
18
19
19
* [ Documentation] ( https://docs.rs/ggemini/latest/ggemini/ )
20
20
21
+ ### Example
22
+
23
+ ``` rust
24
+ use gtk :: gio :: * ;
25
+ use gtk :: glib :: * ;
26
+
27
+ use ggemini :: client :: {
28
+ connection :: {
29
+ response :: meta :: {Mime , Status },
30
+ Response ,
31
+ },
32
+ Client , Error ,
33
+ };
34
+
35
+ fn main () -> ExitCode {
36
+ Client :: new (). request_async (
37
+ Uri :: parse (" gemini://geminiprotocol.net/" , UriFlags :: NONE ). unwrap (),
38
+ Priority :: DEFAULT ,
39
+ Cancellable :: new (),
40
+ None , // optional `GTlsCertificate`
41
+ | result : Result <Response , Error >| match result {
42
+ Ok (response ) => {
43
+ match response . meta. status {
44
+ // route by status code
45
+ Status :: Success => match response . meta. mime {
46
+ // handle `GIOStream` by content type
47
+ Some (Mime :: TextGemini ) => todo! (),
48
+ _ => todo! (),
49
+ },
50
+ _ => todo! (),
51
+ }
52
+ }
53
+ Err (e ) => todo! (" {e}" ),
54
+ },
55
+ );
56
+ ExitCode :: SUCCESS
57
+ }
58
+ ```
59
+
21
60
## See also
22
61
23
62
* [ ggemtext] ( https://github.com/YGGverse/ggemtext ) - Glib-oriented Gemtext API
You can’t perform that action at this time.
0 commit comments