Previous: , Up: Implementation of XDR   [Contents][Index]


4.2.3 XDR Encoding and Decoding

The following primitives are exported by the (rpc xdr) module. They implement the encoding of Scheme values to XDR data types, and the decoding of binary XDR data to Scheme values. The exact mapping between XDR data types and Scheme data types has been discussed earlier.

Scheme Procedure: xdr-encode! bv index type value

Encode value (a suitable Scheme value), using XDR type type, into bytevector bv at index. Return the index where encoding ended.

bv should be an R6RS bytevector large enough to hold the XDR representation of value according to type. To that end, users may rely on xdr-type-size (see XDR Type Representations).

Error conditions sub-classing &xdr-error may be raised during encoding. The exact exceptions that may be raised are type-dependent and have been discussed in the previous sections.

Scheme Procedure: xdr-decode type port

Decode from port (a binary input port) a value of XDR type type. Return the decoded value.

Error conditions sub-classing &xdr-error may be raised during encoding. The exact exceptions that may be raised are type-dependent and have been discussed in the previous sections.