Expand description
An idiomatic Rust client for Gotify.
§Overview
By default, this crate only exposes the Client::health()
,
Client::version()
methods.
All other categories of endpoints must be enabled by the corresponding feature flags.
Table of available feature flags
Most methods that send data to Gotify’s API use the
builder pattern
for a more readable API and better support of future additions to Gotify’s API.
If an optional parameter is added to an endpoint, it can be be added
as a builder method without causing to much breakage.
All builders implement IntoFuture
, so those
methods can also be await
ed directly, just as if they were regular async methods.
§Examples
§Creating a message
ⓘ
let client: gotify::AppClient = gotify::Client::new(GOTIFY_URL, GOTIFY_APP_TOKEN)?;
client.create_message("Lorem ipsum dolor sit amet").with_title("Lorem Ipsum").await?;
§Listening for new messages
ⓘ
use futures_util::StreamExt;
let client: gotify::ClientClient = gotify::Client::new(GOTIFY_URL, GOTIFY_CLIENT_TOKEN)?;
let mut messages = client.stream_messages().await?;
while let Some(result) = messages.next().await {
let message = result?;
println!("{message:#?}")
}
Modules§
- builder
- Builder structs used by some methods that send data to Gotify’s API.
- models
- JSON models returned by Gotify’s API.
Structs§
- AppToken
app
- Marks a client as authenticated to create messages.
- Client
- A client for a specific Gotify server. The main entrypoint of this crate.
- Client
Token client-core
- Marks a client as authenticated to manage the server.
- Unauthenticated
- Marks a client as unauthenticated.
Enums§
- Error
- Errors that can occur when accessing an API endpoint.
- Init
Error - Errors that can occur when creating or authenticating a
Client
. - Websocket
Connect Error websocket
- Errors that can occur when initializing the websocket connection.
- Websocket
Error websocket
- Errors that can occur when the websocket is established.
Traits§
- Token
Type - Sealed trait to represent an
AppToken
orClientToken
.
Type Aliases§
- AppClient
app
- A client that is authenticated to create messages.
- Client
Client client-core
- A client that is authenticated to manage the server.
- Result
- Alias for the
Result
returned when accessing an API endpoint. - Unauthenticated
Client - A client that is unauthenticated.