https://github.com/diogo464/subsonic-types
Subsonic API types
https://github.com/diogo464/subsonic-types
rust subsonic subsonic-library
Last synced: 4 months ago
JSON representation
Subsonic API types
- Host: GitHub
- URL: https://github.com/diogo464/subsonic-types
- Owner: diogo464
- License: mit
- Created: 2023-02-17T17:04:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-18T03:28:17.000Z (8 months ago)
- Last Synced: 2025-06-17T08:03:23.389Z (4 months ago)
- Topics: rust, subsonic, subsonic-library
- Language: Rust
- Homepage:
- Size: 242 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[]()
[](https://crates.io/crates/subsonic-types)
[](https://docs.rs/subsonic-types)
# subsonic-typesSubsonic API types.
## Example
### Creating a ping request to a local subsonic server.
```rust
use reqwest::blocking::get;
use subsonic_types::{
common::Version,
request::{self, SubsonicRequest, Authentication, Request},
response::{Response, ResponseStatus, ResponseBody},
};fn main() -> Result<(), Box> {
let base_url = "http://localhost:3000";
let ping = Request {
username: "admin".into(),
authentication: Authentication::Password("admin".into()),
version: Version::LATEST,
client: "ping-example".into(),
format: None,
body: request::system::Ping,
};
let request_url = format!("{}{}?{}", base_url, request::system::Ping::PATH, ping.to_query());
assert_eq!(
request_url,
"http://localhost:3000/rest/ping?u=admin&p=admin&v=1.16.1&c=ping-example"
);// let response_contents = get(&request_url)?.text()?;
let response_contents = r#""#;
let response = Response::from_xml(response_contents)?;
assert_eq!(
response,
Response { status: ResponseStatus::Ok, version: Version::new(1, 16, 1), body: ResponseBody::Empty }
);
Ok(())
}
```