Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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.