Struct OpenOptions

Source
pub struct OpenOptions { /* private fields */ }
Expand description

Flags and parameters which control how a PosixMq message queue is opened or created.

Implementations§

Source§

impl OpenOptions

Source

pub fn readonly() -> Self

Open message queue for receiving only.

Source

pub fn writeonly() -> Self

Open message queue for sending only.

Source

pub fn readwrite() -> Self

Open message queue both for sending and receiving.

Source

pub fn mode(&mut self, mode: u32) -> &mut Self

Set permissions to create the queue with.

Some bits might be cleared by the process’s umask when creating the queue, and unknown bits are ignored.

This field is ignored if the queue already exists or should not be created. If this method is not called, queues are created with mode 600.

Source

pub fn max_msg_len(&mut self, max_msg_len: usize) -> &mut Self

Set the maximum size of each message.

recv() will fail if given a buffer smaller than this value.

If max_msg_len and capacity are both zero (or not set), the queue will be created with a maximum length and capacity decided by the operating system.
If this value is specified, capacity should also be, or opening the message queue might fail.

Source

pub fn capacity(&mut self, capacity: usize) -> &mut Self

Set the maximum number of messages in the queue.

When the queue is full, further send()s will either block or fail with an error of type ErrorKind::WouldBlock.

If both capacity and max_msg_len are zero (or not set), the queue will be created with a maximum length and capacity decided by the operating system.
If this value is specified, max_msg_len should also be, or opening the message queue might fail.

Source

pub fn create(&mut self) -> &mut Self

Create message queue if it doesn’t exist.

Source

pub fn create_new(&mut self) -> &mut Self

Create a new queue, failing if the queue already exists.

Source

pub fn existing(&mut self) -> &mut Self

Require the queue to already exist, failing if it doesn’t.

Source

pub fn nonblocking(&mut self) -> &mut Self

Open the message queue in non-blocking mode.

This must be done if you want to use the message queue with mio.

Source

pub fn open<N: AsRef<[u8]> + ?Sized>(&self, name: &N) -> Result<PosixMq, Error>

Open a queue with the specified options.

If the name doesn’t start with a ‘/’, one will be prepended.

§Errors
  • Queue doesn’t exist (ENOENT) => ErrorKind::NotFound
  • Name is just “/” (ENOENT) or is empty => ErrorKind::NotFound
  • Queue already exists (EEXISTS) => ErrorKind::AlreadyExists
  • Not permitted to open in this mode (EACCESS) => ErrorKind::PermissionDenied
  • More than one ‘/’ in name (EACCESS) => ErrorKind::PermissionDenied
  • Invalid capacities (EINVAL) => ErrorKind::InvalidInput
  • Capacities too high (EMFILE) => ErrorKind::Other
  • Posix message queues are disabled (ENOSYS) => ErrorKind::Other
  • Name contains ‘\0’ => ErrorKind::InvalidInput
  • Name is too long (ENAMETOOLONG) => ErrorKind::Other
  • Unlikely (ENFILE, EMFILE, ENOMEM, ENOSPC) => ErrorKind::Other
  • Possibly other
Source

pub fn open_c(&self, name: &CStr) -> Result<PosixMq, Error>

Open a queue with the specified options and without inspecting name or allocating.

This can on NetBSD be used to access message queues with names that doesn’t start with a ‘/’.

§Errors
  • Queue doesn’t exist (ENOENT) => ErrorKind::NotFound
  • Name is just “/” (ENOENT) => ErrorKind::NotFound
  • Queue already exists (EEXISTS) => ErrorKind::AlreadyExists
  • Not permitted to open in this mode (EACCESS) => ErrorKind::PermissionDenied
  • More than one ‘/’ in name (EACCESS) => ErrorKind::PermissionDenied
  • Invalid capacities (EINVAL) => ErrorKind::InvalidInput
  • Posix message queues are disabled (ENOSYS) => ErrorKind::Other
  • Name is empty (EINVAL) => ErrorKind::InvalidInput
  • Name is too long (ENAMETOOLONG) => ErrorKind::Other
  • Unlikely (ENFILE, EMFILE, ENOMEM, ENOSPC) => ErrorKind::Other
  • Possibly other

Trait Implementations§

Source§

impl Clone for OpenOptions

Source§

fn clone(&self) -> OpenOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OpenOptions

Source§

fn fmt(&self, fmtr: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for OpenOptions

Source§

fn eq(&self, other: &OpenOptions) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for OpenOptions

Source§

impl Eq for OpenOptions

Source§

impl StructuralPartialEq for OpenOptions

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.