Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timgabets/sp-xml
Rust community library for serializaing/deserializing IBM Safer Payments® XML messages.
https://github.com/timgabets/sp-xml
Last synced: about 2 months ago
JSON representation
Rust community library for serializaing/deserializing IBM Safer Payments® XML messages.
- Host: GitHub
- URL: https://github.com/timgabets/sp-xml
- Owner: timgabets
- License: mit
- Created: 2020-06-01T15:00:03.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-07-06T16:42:12.000Z (over 4 years ago)
- Last Synced: 2024-08-09T21:19:08.468Z (5 months ago)
- Language: Rust
- Size: 23.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## SP XML
![License: MIT](https://img.shields.io/crates/l/sp-xml)
[![Build Status](https://travis-ci.org/timgabets/sp-xml.svg?branch=master)](https://travis-ci.org/timgabets/sp-xml)
[![Crates.io](https://img.shields.io/crates/v/sp_xml.svg)](https://crates.io/crates/sp-xml)Rust community library for serializaing/deserializing IBM Safer Payments® XML messages.
### Usage
```toml
[dependencies]
sp-xml = "0.1"
``````rust
use sp_xml::{SPRequest, SPResponse};let s = r#"
iddqd
aaaa
231231
54656456
127
bbbbb
ccccc
ddddd
eee
2020-04-27 12:00:00
36028797018963968
"#;// Deserializing request
let req = SPRequest::new(s.as_bytes());
println!("{:?}", req);// Applying logic on deserialized request, e.g. generating and assinging Message ID:
req.gen_message_id();// Serializing request
let msg : String = req.serialize().unwrap();// Sending the data over TCP stream:
s.write_all(&msg.as_bytes()).await?;
``````rust
let s = r##"
"##;// Deserializing response
let resp = SPResponse::new(s.as_bytes());
println!("{:?}", resp);// Applying logic on deserialized response, e.g. checking message ID:
println!("{:?}", resp.message_id);// Serializing Response
let serialized = res.serialize().unwrap();
println!("{:?}", serialized);// Sending serialized response in HTTP payload
Ok(HttpResponse::Ok()
.content_type("text/xml")
.body(serialized))
```Check [lakgves](https://github.com/timgabets/lakgves) for more examples.