Skip to content

Commit 8ed5521

Browse files
committed
Run rustfmt on mqueue.rs
1 parent 5d50193 commit 8ed5521

File tree

1 file changed

+43
-19
lines changed

1 file changed

+43
-19
lines changed

src/mqueue.rs

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
use {Errno, Result};
66

7-
use libc::{self, c_char,c_long,mode_t,mqd_t,size_t};
7+
use libc::{self, c_char, c_long, mode_t, mqd_t, size_t};
88
use std::ffi::CString;
99
use sys::stat::Mode;
1010
use std::mem;
@@ -30,28 +30,31 @@ libc_bitflags!{
3030
#[repr(C)]
3131
#[derive(Clone, Copy)]
3232
pub struct MqAttr {
33-
mq_attr: libc::mq_attr
33+
mq_attr: libc::mq_attr,
3434
}
3535

3636
impl PartialEq<MqAttr> for MqAttr {
3737
fn eq(&self, other: &MqAttr) -> bool {
3838
let self_attr = self.mq_attr;
3939
let other_attr = other.mq_attr;
40-
self_attr.mq_flags == other_attr.mq_flags &&
41-
self_attr.mq_maxmsg == other_attr.mq_maxmsg &&
42-
self_attr.mq_msgsize == other_attr.mq_msgsize &&
43-
self_attr.mq_curmsgs == other_attr.mq_curmsgs
40+
self_attr.mq_flags == other_attr.mq_flags && self_attr.mq_maxmsg == other_attr.mq_maxmsg &&
41+
self_attr.mq_msgsize == other_attr.mq_msgsize &&
42+
self_attr.mq_curmsgs == other_attr.mq_curmsgs
4443
}
4544
}
4645

4746
impl MqAttr {
48-
pub fn new(mq_flags: c_long, mq_maxmsg: c_long, mq_msgsize: c_long, mq_curmsgs: c_long) -> MqAttr {
47+
pub fn new(mq_flags: c_long,
48+
mq_maxmsg: c_long,
49+
mq_msgsize: c_long,
50+
mq_curmsgs: c_long)
51+
-> MqAttr {
4952
let mut attr = unsafe { mem::uninitialized::<libc::mq_attr>() };
5053
attr.mq_flags = mq_flags;
5154
attr.mq_maxmsg = mq_maxmsg;
5255
attr.mq_msgsize = mq_msgsize;
5356
attr.mq_curmsgs = mq_curmsgs;
54-
MqAttr{mq_attr: attr}
57+
MqAttr { mq_attr: attr }
5558
}
5659

5760
pub fn flags(&self) -> c_long {
@@ -60,14 +63,19 @@ impl MqAttr {
6063
}
6164

6265

63-
pub fn mq_open(name: &CString, oflag: MQ_OFlag, mode: Mode, attr: Option<&MqAttr>) -> Result<mqd_t> {
66+
pub fn mq_open(name: &CString,
67+
oflag: MQ_OFlag,
68+
mode: Mode,
69+
attr: Option<&MqAttr>)
70+
-> Result<mqd_t> {
6471
let res = match attr {
65-
Some(mq_attr) => {
66-
unsafe { libc::mq_open(name.as_ptr(), oflag.bits(), mode.bits() as mode_t, &mq_attr.mq_attr as *const libc::mq_attr) }
72+
Some(mq_attr) => unsafe {
73+
libc::mq_open(name.as_ptr(),
74+
oflag.bits(),
75+
mode.bits() as mode_t,
76+
&mq_attr.mq_attr as *const libc::mq_attr)
6777
},
68-
None => {
69-
unsafe { libc::mq_open(name.as_ptr(), oflag.bits()) }
70-
}
78+
None => unsafe { libc::mq_open(name.as_ptr(), oflag.bits()) },
7179
};
7280
Errno::result(res)
7381
}
@@ -77,19 +85,29 @@ pub fn mq_unlink(name: &CString) -> Result<()> {
7785
Errno::result(res).map(drop)
7886
}
7987

80-
pub fn mq_close(mqdes: mqd_t) -> Result<()> {
88+
pub fn mq_close(mqdes: mqd_t) -> Result<()> {
8189
let res = unsafe { libc::mq_close(mqdes) };
8290
Errno::result(res).map(drop)
8391
}
8492

8593
pub fn mq_receive(mqdes: mqd_t, message: &mut [u8], msg_prio: &mut u32) -> Result<usize> {
8694
let len = message.len() as size_t;
87-
let res = unsafe { libc::mq_receive(mqdes, message.as_mut_ptr() as *mut c_char, len, msg_prio as *mut u32) };
95+
let res = unsafe {
96+
libc::mq_receive(mqdes,
97+
message.as_mut_ptr() as *mut c_char,
98+
len,
99+
msg_prio as *mut u32)
100+
};
88101
Errno::result(res).map(|r| r as usize)
89102
}
90103

91104
pub fn mq_send(mqdes: mqd_t, message: &[u8], msq_prio: u32) -> Result<()> {
92-
let res = unsafe { libc::mq_send(mqdes, message.as_ptr() as *const c_char, message.len(), msq_prio) };
105+
let res = unsafe {
106+
libc::mq_send(mqdes,
107+
message.as_ptr() as *const c_char,
108+
message.len(),
109+
msq_prio)
110+
};
93111
Errno::result(res).map(drop)
94112
}
95113

@@ -115,7 +133,10 @@ pub fn mq_setattr(mqd: mqd_t, newattr: &MqAttr) -> Result<MqAttr> {
115133
/// Returns the old attributes
116134
pub fn mq_set_nonblock(mqd: mqd_t) -> Result<(MqAttr)> {
117135
let oldattr = try!(mq_getattr(mqd));
118-
let newattr = MqAttr::new(O_NONBLOCK.bits() as c_long, oldattr.mq_attr.mq_maxmsg, oldattr.mq_attr.mq_msgsize, oldattr.mq_attr.mq_curmsgs);
136+
let newattr = MqAttr::new(O_NONBLOCK.bits() as c_long,
137+
oldattr.mq_attr.mq_maxmsg,
138+
oldattr.mq_attr.mq_msgsize,
139+
oldattr.mq_attr.mq_curmsgs);
119140
mq_setattr(mqd, &newattr)
120141
}
121142

@@ -124,6 +145,9 @@ pub fn mq_set_nonblock(mqd: mqd_t) -> Result<(MqAttr)> {
124145
/// Returns the old attributes
125146
pub fn mq_remove_nonblock(mqd: mqd_t) -> Result<(MqAttr)> {
126147
let oldattr = try!(mq_getattr(mqd));
127-
let newattr = MqAttr::new(0, oldattr.mq_attr.mq_maxmsg, oldattr.mq_attr.mq_msgsize, oldattr.mq_attr.mq_curmsgs);
148+
let newattr = MqAttr::new(0,
149+
oldattr.mq_attr.mq_maxmsg,
150+
oldattr.mq_attr.mq_msgsize,
151+
oldattr.mq_attr.mq_curmsgs);
128152
mq_setattr(mqd, &newattr)
129153
}

0 commit comments

Comments
 (0)