Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

facet-xdr

Binry encoding and decoding of XDR (RFC4506) data.

Reference

XDR IDL Rust
int i32
unsigned int u32
enum Unit enum
bool bool
hyper i64
unsigned hyper u64
float f32
double f64
quadruple Not currently supported
opaque [n] [u8; N]
opaque<> Vec<u8> or &[u8]
string<> String
Fixed length array [n] [T; N]
Variable length array <> Vec<T> or &[T]
struct struct
union enum
void Unit struct or unit variant
* (optional-data) Option

Example Code

The example from chapter 7 of RFC4506 can be represented in Rust like so:

#[derive(Debug, Facet)]
#[repr(u32)]
enum FileType {
    Text,
    Data { creator: String },
    Exec { interpretor: String },
}

#[derive(Debug, Facet, PartialEq)]
struct File {
    filename: String,
    filetype: FileType,
    owner: String,
    data: Vec<u8>,
}

About

XDR encoding and decoding using facet-rs

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages