From 40680a3648cc7d598d428d6fe1752a2be9bfd547 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 25 Mar 2024 00:59:25 +0000 Subject: docs(examples): comment examples --- examples/request_blocking.rs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'examples/request_blocking.rs') diff --git a/examples/request_blocking.rs b/examples/request_blocking.rs index fed1c41..8d6e513 100644 --- a/examples/request_blocking.rs +++ b/examples/request_blocking.rs @@ -16,11 +16,36 @@ // Copyright (C) 2022-2022 Fuwn // SPDX-License-Identifier: GPL-3.0-only +//! This example demonstrates Germ's capabilities for performing a blocking +//! request to a Gemini capsule. + fn main() { - match germ::request::blocking::request( - &url::Url::parse("gemini://fuwn.me").unwrap(), - ) { - Ok(response) => println!("{:?}", response), + // Form a valid URL to a Gemini capsule + let url = url::Url::parse("gemini://fuwn.me").unwrap(); + // Perform a blocking request to the Gemini capsule + let request = germ::request::blocking::request(&url); + + match request { + // If the request was successful, print a debug view of the response + Ok(response) => { + // Print the status of the response + println!("{:?}", response.status()); + + // Print the meta string of the response + // + // More detailed meta usage can be found in the `meta` example + println!("{}", response.meta()); + + // Print the content of the response, if present + println!("{:?}", response.content()); + + // Print the size of the response + println!("{:?}", response.size()); + + // Print a debug view of the SSL suite used + println!("{:?}", response.suite()); + } + // If the request was unsuccessful, do nothing Err(_) => {} } } -- cgit v1.2.3