Skip to main content

UdpSocket

Struct UdpSocket 

Source
pub(super) struct UdpSocket {
    family: Domain,
    socket: RefCell<UdpSocket>,
    is_non_block: Cell<bool>,
    is_bound: Cell<bool>,
    io_readiness: RefCell<Readiness>,
    read_timeout: Cell<Option<Duration>>,
    write_timeout: Cell<Option<Duration>>,
    watched: ReadinessWatched,
}

Fields§

§family: Domain

Family of the socket, used to ensure that the socket only binds/connects to addresses of the same family.

§socket: RefCell<UdpSocket>

The underlying host socket.

§is_non_block: Cell<bool>

Whether this fd is non-blocking or not.

§is_bound: Cell<bool>

Whether the socket is implicitly or explicitly bound to an address.

§io_readiness: RefCell<Readiness>

The current blocking I/O readiness of the file description.

§read_timeout: Cell<Option<Duration>>

Read timeout of the socket. None means that reads can block indefinitely. The timeout is applied to the monotonic clock (the Unix specification doesn’t specify which clock to use, but the monotonic clock is more common for relative timeouts). This is ignored when the socket is non-blocking.

§write_timeout: Cell<Option<Duration>>

Write timeout of the socket. None means that writes can block indefinitely. The timeout is applied to the monotonic clock (the Unix specification doesn’t specify which clock to use, but the monotonic clock is more common for relative timeouts). This is ignored when the socket is non-blocking.

§watched: ReadinessWatched

State for being watched by epoll.

Implementations§

Source§

impl UdpSocket

Source

pub fn new<'tcx>( family: Domain, is_non_block: bool, ecx: &mut MiriInterpCx<'tcx>, ) -> Result<FileDescriptionRef<Self>>

Trait Implementations§

Source§

impl Debug for UdpSocket

Source§

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

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

impl FileDescription for UdpSocket

Source§

fn name(&self) -> &'static str

Source§

fn as_unix( self: FileDescriptionRef<Self>, ) -> FileDescriptionRef<dyn UnixFileDescription>

Converts this FD into a unix file description. Must succeed for all FD types that can be created on Unix targets!
Source§

fn readiness_watched(&self) -> Option<&ReadinessWatched>

Get the ReadinessWatched of the file description.
Source§

fn readiness(&self) -> Readiness

Get the current I/O readiness of the file description.
Source§

fn read<'tcx>( self: FileDescriptionRef<Self>, _communicate_allowed: bool, _ptr: Pointer, _len: usize, _ecx: &mut MiriInterpCx<'tcx>, _finish: DynMachineCallback<'tcx, Result<usize, IoError>>, ) -> InterpResult<'tcx>

Reads as much as possible into the given buffer ptr. len indicates how many bytes we should try to read. Read more
Source§

fn write<'tcx>( self: FileDescriptionRef<Self>, _communicate_allowed: bool, _ptr: Pointer, _len: usize, _ecx: &mut MiriInterpCx<'tcx>, _finish: DynMachineCallback<'tcx, Result<usize, IoError>>, ) -> InterpResult<'tcx>

Writes as much as possible from the given buffer ptr. len indicates how many bytes we should try to write. Read more
Source§

fn short_fd_operations(&self) -> bool

Determines whether this FD non-deterministically has its reads and writes shortened.
Source§

fn seek<'tcx>( &self, _communicate_allowed: bool, _offset: SeekFrom, ) -> InterpResult<'tcx, Result<u64>>

Seeks to the given offset (which can be relative to the beginning, end, or current position). Returns the new position from the start of the stream.
Source§

fn metadata<'tcx>( &self, _communicate_allowed: bool, ) -> InterpResult<'tcx, Either<Result<Metadata>, &'static str>>

Returns the metadata for this FD, if available. This is either host metadata, or a non-file-backed-FD type. The latter is for now represented as a string storing the libc name of the mode so we only support that kind of metadata on Unix targets.
Source§

fn is_tty(&self, _communicate_allowed: bool) -> bool

Source§

impl SourceFileDescription for UdpSocket

Source§

fn with_source( &self, f: &mut dyn FnMut(&mut dyn Source) -> Result<()>, ) -> Result<()>

Invoke f on the source inside self.
Source§

fn get_readiness_mut(&self) -> RefMut<'_, Readiness>

Get a mutable reference to the readiness of the source.
Source§

impl UnixFileDescription for UdpSocket

Source§

fn get_flags<'tcx>( &self, ecx: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Scalar>

Implementation of fcntl(F_GETFL) for this FD.
Source§

fn set_flags<'tcx>( &self, flag: i32, ecx: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Scalar>

Implementation of fcntl(F_SETFL) for this FD.
Source§

fn as_socket( self: FileDescriptionRef<Self>, ) -> Option<FileDescriptionRef<dyn UnixSocketFileDescription>>

Returns this file description as a Unix socket, if it represents one.
Source§

fn pread<'tcx>( &self, _communicate_allowed: bool, _offset: u64, _ptr: Pointer, _len: usize, _ecx: &mut MiriInterpCx<'tcx>, _finish: DynMachineCallback<'tcx, Result<usize, IoError>>, ) -> InterpResult<'tcx>

Reads as much as possible into the given buffer ptr from a given offset. len indicates how many bytes we should try to read. dest is where the return value should be stored: number of bytes read, or -1 in case of error.
Source§

fn pwrite<'tcx>( &self, _communicate_allowed: bool, _ptr: Pointer, _len: usize, _offset: u64, _ecx: &mut MiriInterpCx<'tcx>, _finish: DynMachineCallback<'tcx, Result<usize, IoError>>, ) -> InterpResult<'tcx>

Writes as much as possible from the given buffer ptr starting at a given offset. ptr is the pointer to the user supplied read buffer. len indicates how many bytes we should try to write. dest is where the return value should be stored: number of bytes written, or -1 in case of error.
Source§

fn flock<'tcx>( &self, _communicate_allowed: bool, _op: FlockOp, ) -> InterpResult<'tcx, Result<()>>

Source§

impl UnixSocketFileDescription for UdpSocket

Source§

fn bind<'tcx>( self: FileDescriptionRef<Self>, communicate_allowed: bool, address: SocketAddr, ecx: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Result<(), IoError>>

Bind the socket to address.
Source§

fn connect<'tcx>( self: FileDescriptionRef<Self>, communicate_allowed: bool, address: SocketAddr, ecx: &mut MiriInterpCx<'tcx>, finish: DynMachineCallback<'tcx, Result<(), IoError>>, ) -> InterpResult<'tcx>

Connect the socket to address.
Source§

fn setsockopt<'tcx>( self: FileDescriptionRef<Self>, level: i32, option: i32, value_ptr: Pointer, value_len: u64, ecx: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Result<(), IoError>>

Set the socket option option on level. value_ptr points to the new value of the socket option, and value_len contains the amount of bytes the value uses at value_ptr.
Source§

fn getsockopt<'tcx>( self: FileDescriptionRef<Self>, level: i32, option: i32, ecx: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Result<MPlaceTy<'tcx>, IoError>>

Get the value of a socket option option on level.
Source§

fn getsockname<'tcx>( self: FileDescriptionRef<Self>, communicate_allowed: bool, _ecx: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Result<SocketAddr, IoError>>

Get the local address of the socket.
Source§

fn getpeername<'tcx>( self: FileDescriptionRef<Self>, communicate_allowed: bool, ecx: &mut MiriInterpCx<'tcx>, finish: DynMachineCallback<'tcx, Result<SocketAddr, IoError>>, ) -> InterpResult<'tcx>

Get the remote address of the socket.
Source§

fn set_read_timeout<'tcx>( self: FileDescriptionRef<Self>, timeout: Option<Duration>, ) -> InterpResult<'tcx>

Set the read timeout for the socket. If timeout is None, then read operations should block indefinitely. Otherwise, read operations should block until timeout is expired.
Source§

fn get_read_timeout<'tcx>( self: FileDescriptionRef<Self>, ) -> InterpResult<'tcx, Option<Duration>>

Get the read timeout for the socket.
Source§

fn set_write_timeout<'tcx>( self: FileDescriptionRef<Self>, timeout: Option<Duration>, ) -> InterpResult<'tcx>

Set the write timeout for the socket. If timeout is None, then write operations should block indefinitely. Otherwise, write operations should block until timeout is expired.
Source§

fn get_write_timeout<'tcx>( self: FileDescriptionRef<Self>, ) -> InterpResult<'tcx, Option<Duration>>

Get the write timeout for the socket.
Source§

fn with_socket_ref<T>(&self, cb: impl FnOnce(SockRef<'_>) -> T) -> Result<T, ()>
where Self: Sized,

If the shimmed socket contains an underlying host socket, the cb callback function is invoked with a [socket2::SockRef] to the underlying host socket and Ok with the return value of the callback is returned. Otherwise, when the shimmed socket is not backed by a host socket, Err is returned.
Source§

fn listen<'tcx>( self: FileDescriptionRef<Self>, _communicate_allowed: bool, _backlog: i32, _ecx: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Result<(), IoError>>

Start listening on the socket. backlog specifies how many pending incoming connections can exist at the same time before new requests are rejected.
Source§

fn accept<'tcx>( self: FileDescriptionRef<Self>, _communicate_allowed: bool, _is_client_sock_non_block: bool, _ecx: &mut MiriInterpCx<'tcx>, _finish: DynMachineCallback<'tcx, Result<(i32, SocketAddr), IoError>>, ) -> InterpResult<'tcx>

Accept an incoming connection on the socket. is_client_sock_non_block specifies whether the newly accepted client connection should be non-blocking. After a successful accept, finish should be called with a tuple containing the file descriptor of the peer socket and it’s address.
Source§

fn recv<'tcx>( self: FileDescriptionRef<Self>, _communicate_allowed: bool, _ptr: Pointer, _len: usize, _is_peek: bool, _is_non_block: bool, _ecx: &mut MiriInterpCx<'tcx>, _finish: DynMachineCallback<'tcx, Result<(usize, Option<SocketAddr>), IoError>>, ) -> InterpResult<'tcx>

Receive data on the socket into the given buffer ptr and return the socket address from where the data originated. len indicates how many bytes we should try to receive. is_peek specifies whether the receive removes the bytes from the receive buffer (false) or leaves them in the receive buffer (true). is_non_block specifies whether the receive operation is non-blocking. After a successful receive, finish should be called with a tuple containing the amount of bytes received and the socket address from where the data originated, should it be provided by the protocol.
Source§

fn send<'tcx>( self: FileDescriptionRef<Self>, _communicate_allowed: bool, _ptr: Pointer, _len: usize, _is_non_block: bool, _dest_addr: Option<SocketAddr>, _ecx: &mut MiriInterpCx<'tcx>, _finish: DynMachineCallback<'tcx, Result<usize, IoError>>, ) -> InterpResult<'tcx>

Send data from the given buffer ptr into the socket. len indicates how many bytes we should try to send. is_non_block specifies whether the send operation is non-blocking. dest_addr optionally contains a socket address to which the data should be sent instead of the default destination address. After a successful send, finish should be called with the amount of bytes sent.
Source§

fn shutdown<'tcx>( self: FileDescriptionRef<Self>, _communicate_allowed: bool, _how: Shutdown, _ecx: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Result<(), IoError>>

Shut down the read and/or the write end of the socket.
Source§

fn take_error<'tcx>( self: FileDescriptionRef<Self>, _ecx: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Option<Error>>

Get the stored I/O error of the socket, if any exists. This method should consume the stored error.

Auto Trait Implementations§

§

impl !DynSend for UdpSocket

§

impl !DynSync for UdpSocket

§

impl !Freeze for UdpSocket

§

impl !RefUnwindSafe for UdpSocket

§

impl !Send for UdpSocket

§

impl !Sync for UdpSocket

§

impl !UnwindSafe for UdpSocket

§

impl Forget for UdpSocket

§

impl Unpin for UdpSocket

§

impl UnsafeUnpin for UdpSocket

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> FileDescriptionExt for T
where T: FileDescription + 'static,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 176 bytes