bread-graphics/breadx

constans for request length?

Closed this issue · 2 comments

For code bellow where I should get 12?

    let req = QueryVersionRequest {
        req_type: xfixes_ext.major_opcode,
        length: 12,
        client_major_version: 6,
        client_minor_version: 0,
    };
    let cookie = conn.send_request(req)?;
    let reply = conn.resolve_request(cookie)?;

For now I took it from /usr/include/X11/extensions/xfixesproto.h

#define sz_xXFixesQueryVersionReq   12

But would be nice if there is such constant in breadx.

You don't need it. You would use:

use breadx::auto::AsByteSequence;
req.length = req.size();

However, this is already computed by send_request. In reality, you can do:

    let req = QueryVersionRequest {
        req_type: xfixes_ext.major_opcode,
        client_major_version: 6,
        client_minor_version: 0,
        ..Default::default()
    };

req.length = req.size();

But this doesn't compile.
Why type of size() (usize) and length (u16) have different types?