#[repr(transparent)]pub struct Socket { /* private fields */ }
Expand description
A Socket
is a low-level networking primitive. It is a more or less
direct mapping of the BSD socket API in a portable GObject based API.
It supports both the UNIX socket implementations and winsock2 on Windows.
Socket
is the platform independent base upon which the higher level
network primitives are based. Applications are not typically meant to
use it directly, but rather through classes like SocketClient
,
SocketService
and SocketConnection
. However there may be cases where
direct use of Socket
is useful.
Socket
implements the Initable
interface, so if it is manually constructed
by e.g. glib::Object::new()
you must call InitableExt::init()
and check the
results before using the object. This is done automatically in
new()
and from_fd()
, so these functions can return
None
.
Sockets operate in two general modes, blocking or non-blocking. When
in blocking mode all operations (which don’t take an explicit blocking
parameter) block until the requested operation
is finished or there is an error. In non-blocking mode all calls that
would block return immediately with a IOErrorEnum::WouldBlock
error.
To know when a call would successfully run you can call SocketExt::condition_check()
,
or SocketExt::condition_wait()
. You can also use g_socket_create_source()
and
attach it to a glib::MainContext
to get callbacks when I/O is possible.
Note that all sockets are always set to non blocking mode in the system, and
blocking mode is emulated in GSocket.
When working in non-blocking mode applications should always be able to
handle getting a IOErrorEnum::WouldBlock
error even when some other
function said that I/O was possible. This can easily happen in case
of a race condition in the application, but it can also happen for other
reasons. For instance, on Windows a socket is always seen as writable
until a write returns IOErrorEnum::WouldBlock
.
GSockets
can be either connection oriented or datagram based.
For connection oriented types you must first establish a connection by
either connecting to an address or accepting a connection from another
address. For connectionless socket types the target/source address is
specified or received in each I/O operation.
All socket file descriptors are set to be close-on-exec.
Note that creating a Socket
causes the signal SIGPIPE
to be
ignored for the remainder of the program. If you are writing a
command-line utility that uses Socket
, you may need to take into
account the fact that your program will not automatically be killed
if it tries to write to stdout
after it has been closed.
Like most other APIs in GLib, Socket
is not inherently thread safe. To use
a Socket
concurrently from multiple threads, you must implement your own
locking.
Properties
blocking
Readable | Writeable
broadcast
Whether the socket should allow sending to broadcast addresses.
Readable | Writeable
family
Readable | Writeable | Construct Only
fd
Readable | Writeable | Construct Only
keepalive
Readable | Writeable
listen-backlog
Readable | Writeable
local-address
Readable
multicast-loopback
Whether outgoing multicast packets loop back to the local host.
Readable | Writeable
multicast-ttl
Time-to-live out outgoing multicast packets
Readable | Writeable
protocol
Readable | Writeable | Construct Only
remote-address
Readable
timeout
The timeout in seconds on socket I/O
Readable | Writeable
ttl
Time-to-live for outgoing unicast packets
Readable | Writeable
type
Readable | Writeable | Construct Only
Implements
SocketExt
, glib::ObjectExt
, DatagramBasedExt
, InitableExt
, SocketExtManual
, DatagramBasedExtManual
Implementations§
source§impl Socket
impl Socket
sourcepub unsafe fn from_fd(fd: impl IntoRawFd) -> Result<Socket, Error>
pub unsafe fn from_fd(fd: impl IntoRawFd) -> Result<Socket, Error>
Creates a new Socket
from a native file descriptor
or winsock SOCKET handle.
This reads all the settings from the file descriptor so that
all properties should work. Note that the file descriptor
will be set to non-blocking mode, independent on the blocking
mode of the Socket
.
On success, the returned Socket
takes ownership of fd
. On failure, the
caller must close fd
themselves.
Since GLib 2.46, it is no longer a fatal error to call this on a non-socket
descriptor. Instead, a GError will be set with code IOErrorEnum::Failed
fd
a native socket file descriptor.
Returns
a Socket
or None
on error.
Free the returned object with g_object_unref()
.
pub unsafe fn from_socket(socket: impl IntoRawSocket) -> Result<Socket, Error>
source§impl Socket
impl Socket
pub const NONE: Option<&'static Socket> = None
sourcepub fn new(
family: SocketFamily,
type_: SocketType,
protocol: SocketProtocol
) -> Result<Socket, Error>
pub fn new( family: SocketFamily, type_: SocketType, protocol: SocketProtocol ) -> Result<Socket, Error>
Creates a new Socket
with the defined family, type and protocol.
If protocol
is 0 (SocketProtocol::Default
) the default protocol type
for the family and type is used.
The protocol
is a family and type specific int that specifies what
kind of protocol to use. SocketProtocol
lists several common ones.
Many families only support one protocol, and use 0 for this, others
support several and using 0 means to use the default protocol for
the family and type.
The protocol id is passed directly to the operating
system, so you can use protocols not listed in SocketProtocol
if you
know the protocol number used for it.
family
the socket family to use, e.g. SocketFamily::Ipv4
.
type_
the socket type to use.
protocol
the id of the protocol to use, or 0 for default.
Returns
a Socket
or None
on error.
Free the returned object with g_object_unref()
.
Trait Implementations§
source§impl HasParamSpec for Socket
impl HasParamSpec for Socket
source§impl Ord for Socket
impl Ord for Socket
source§impl<OT: ObjectType> PartialEq<OT> for Socket
impl<OT: ObjectType> PartialEq<OT> for Socket
source§impl<OT: ObjectType> PartialOrd<OT> for Socket
impl<OT: ObjectType> PartialOrd<OT> for Socket
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl StaticType for Socket
impl StaticType for Socket
source§fn static_type() -> Type
fn static_type() -> Type
Self
.impl Eq for Socket
impl IsA<DatagramBased> for Socket
impl IsA<Initable> for Socket
Auto Trait Implementations§
impl RefUnwindSafe for Socket
impl !Send for Socket
impl !Sync for Socket
impl Unpin for Socket
impl UnwindSafe for Socket
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Cast for Twhere
T: ObjectType,
impl<T> Cast for Twhere T: ObjectType,
source§fn upcast<T>(self) -> Twhere
T: ObjectType,
Self: IsA<T>,
fn upcast<T>(self) -> Twhere T: ObjectType, Self: IsA<T>,
T
. Read moresource§fn upcast_ref<T>(&self) -> &Twhere
T: ObjectType,
Self: IsA<T>,
fn upcast_ref<T>(&self) -> &Twhere T: ObjectType, Self: IsA<T>,
T
. Read moresource§fn downcast<T>(self) -> Result<T, Self>where
T: ObjectType,
Self: CanDowncast<T>,
fn downcast<T>(self) -> Result<T, Self>where T: ObjectType, Self: CanDowncast<T>,
T
. Read moresource§fn downcast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
Self: CanDowncast<T>,
fn downcast_ref<T>(&self) -> Option<&T>where T: ObjectType, Self: CanDowncast<T>,
T
. Read moresource§fn dynamic_cast<T>(self) -> Result<T, Self>where
T: ObjectType,
fn dynamic_cast<T>(self) -> Result<T, Self>where T: ObjectType,
T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while upcast
will do many checks at compile-time already. downcast
will
perform the same checks at runtime as dynamic_cast
, but will also ensure some amount of
compile-time safety. Read moresource§fn dynamic_cast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
fn dynamic_cast_ref<T>(&self) -> Option<&T>where T: ObjectType,
T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read moresource§unsafe fn unsafe_cast<T>(self) -> Twhere
T: ObjectType,
unsafe fn unsafe_cast<T>(self) -> Twhere T: ObjectType,
T
unconditionally. Read moresource§unsafe fn unsafe_cast_ref<T>(&self) -> &Twhere
T: ObjectType,
unsafe fn unsafe_cast_ref<T>(&self) -> &Twhere T: ObjectType,
&T
unconditionally. Read moresource§impl<O> DatagramBasedExt for Owhere
O: IsA<DatagramBased>,
impl<O> DatagramBasedExt for Owhere O: IsA<DatagramBased>,
source§fn condition_check(&self, condition: IOCondition) -> IOCondition
fn condition_check(&self, condition: IOCondition) -> IOCondition
self
to perform operations. The
operations specified in condition
are checked for and masked against the
currently-satisfied conditions on self
. The result is returned. Read moresource§impl<O> DatagramBasedExtManual for Owhere
O: IsA<DatagramBased>,
impl<O> DatagramBasedExtManual for Owhere O: IsA<DatagramBased>,
source§fn create_source<F, C>(
&self,
condition: IOCondition,
cancellable: Option<&C>,
name: Option<&str>,
priority: Priority,
func: F
) -> Sourcewhere
F: FnMut(&O, IOCondition) -> Continue + 'static,
C: IsA<Cancellable>,
fn create_source<F, C>( &self, condition: IOCondition, cancellable: Option<&C>, name: Option<&str>, priority: Priority, func: F ) -> Sourcewhere F: FnMut(&O, IOCondition) -> Continue + 'static, C: IsA<Cancellable>,
glib::Source
that can be attached to a glib::MainContext
to monitor for
the availability of the specified condition
on the DatagramBased
. The
glib::Source
keeps a reference to the self
. Read morefn create_source_future<C>( &self, condition: IOCondition, cancellable: Option<&C>, priority: Priority ) -> Pin<Box<dyn Future<Output = IOCondition> + 'static, Global>>where C: IsA<Cancellable>,
fn create_source_stream<C>( &self, condition: IOCondition, cancellable: Option<&C>, priority: Priority ) -> Pin<Box<dyn Stream<Item = IOCondition> + 'static, Global>>where C: IsA<Cancellable>,
source§fn condition_wait(
&self,
condition: IOCondition,
timeout: Option<Duration>,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>
fn condition_wait( &self, condition: IOCondition, timeout: Option<Duration>, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(), Error>
source§fn receive_messages<'v, V, C>(
&self,
messages: &mut [InputMessage<'_>],
flags: i32,
timeout: Option<Duration>,
cancellable: Option<&C>
) -> Result<usize, Error>where
V: IntoIterator<Item = &'v mut [&'v mut [u8]]>,
C: IsA<Cancellable>,
fn receive_messages<'v, V, C>( &self, messages: &mut [InputMessage<'_>], flags: i32, timeout: Option<Duration>, cancellable: Option<&C> ) -> Result<usize, Error>where V: IntoIterator<Item = &'v mut [&'v mut [u8]]>, C: IsA<Cancellable>,
self
in one go. Read moresource§fn send_messages<C>(
&self,
messages: &mut [OutputMessage<'_>],
flags: i32,
timeout: Option<Duration>,
cancellable: Option<&C>
) -> Result<usize, Error>where
C: IsA<Cancellable>,
fn send_messages<C>( &self, messages: &mut [OutputMessage<'_>], flags: i32, timeout: Option<Duration>, cancellable: Option<&C> ) -> Result<usize, Error>where C: IsA<Cancellable>,
self
in one go. Read moresource§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<O> InitableExt for Owhere
O: IsA<Initable>,
impl<O> InitableExt for Owhere O: IsA<Initable>,
source§impl<T> IntoClosureReturnValue for Twhere
T: Into<Value>,
impl<T> IntoClosureReturnValue for Twhere T: Into<Value>,
fn into_closure_return_value(self) -> Option<Value>
source§impl<U> IsSubclassableExt for Uwhere
U: IsClass + ParentClassIs,
impl<U> IsSubclassableExt for Uwhere U: IsClass + ParentClassIs,
fn parent_class_init<T>(class: &mut Class<U>)where T: ObjectSubclass, <U as ParentClassIs>::Parent: IsSubclassable<T>,
fn parent_instance_init<T>(instance: &mut InitializingObject<T>)where T: ObjectSubclass, <U as ParentClassIs>::Parent: IsSubclassable<T>,
source§impl<T> ObjectExt for Twhere
T: ObjectType,
impl<T> ObjectExt for Twhere T: ObjectType,
source§fn is<U>(&self) -> boolwhere
U: StaticType,
fn is<U>(&self) -> boolwhere U: StaticType,
true
if the object is an instance of (can be cast to) T
.source§fn object_class(&self) -> &Class<Object>
fn object_class(&self) -> &Class<Object>
ObjectClass
of the object. Read moresource§fn class_of<U>(&self) -> Option<&Class<U>>where
U: IsClass,
fn class_of<U>(&self) -> Option<&Class<U>>where U: IsClass,
T
. Read moresource§fn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where
U: IsInterface,
fn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where U: IsInterface,
T
of the object. Read moresource§fn set_property_from_value(&self, property_name: &str, value: &Value)
fn set_property_from_value(&self, property_name: &str, value: &Value)
source§fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
source§fn set_properties_from_value(&self, property_values: &[(&str, Value)])
fn set_properties_from_value(&self, property_values: &[(&str, Value)])
source§fn property<V>(&self, property_name: &str) -> Vwhere
V: for<'b> FromValue<'b> + 'static,
fn property<V>(&self, property_name: &str) -> Vwhere V: for<'b> FromValue<'b> + 'static,
property_name
of the object and cast it to the type V. Read moresource§fn property_value(&self, property_name: &str) -> Value
fn property_value(&self, property_name: &str) -> Value
property_name
of the object. Read moresource§fn property_type(&self, property_name: &str) -> Option<Type>
fn property_type(&self, property_name: &str) -> Option<Type>
property_name
of this object. Read moresource§fn find_property(&self, property_name: &str) -> Option<ParamSpec>
fn find_property(&self, property_name: &str) -> Option<ParamSpec>
ParamSpec
of the property property_name
of this object.source§fn list_properties(&self) -> PtrSlice<ParamSpec>
fn list_properties(&self) -> PtrSlice<ParamSpec>
ParamSpec
of the properties of this object.source§fn freeze_notify(&self) -> PropertyNotificationFreezeGuard
fn freeze_notify(&self) -> PropertyNotificationFreezeGuard
source§unsafe fn set_qdata<QD>(&self, key: Quark, value: QD)where
QD: 'static,
unsafe fn set_qdata<QD>(&self, key: Quark, value: QD)where QD: 'static,
key
. Read moresource§unsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>where
QD: 'static,
unsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>where QD: 'static,
key
. Read moresource§unsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>where
QD: 'static,
unsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>where QD: 'static,
key
. Read moresource§unsafe fn set_data<QD>(&self, key: &str, value: QD)where
QD: 'static,
unsafe fn set_data<QD>(&self, key: &str, value: QD)where QD: 'static,
key
. Read moresource§unsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>where
QD: 'static,
unsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>where QD: 'static,
key
. Read moresource§unsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>where
QD: 'static,
unsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>where QD: 'static,
key
. Read moresource§fn block_signal(&self, handler_id: &SignalHandlerId)
fn block_signal(&self, handler_id: &SignalHandlerId)
source§fn unblock_signal(&self, handler_id: &SignalHandlerId)
fn unblock_signal(&self, handler_id: &SignalHandlerId)
source§fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
source§fn stop_signal_emission_by_name(&self, signal_name: &str)
fn stop_signal_emission_by_name(&self, signal_name: &str)
source§fn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
fn connect<F>( &self, signal_name: &str, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
signal_name
on this object. Read moresource§fn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
fn connect_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
signal_id
on this object. Read moresource§fn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value> + 'static,
fn connect_local<F>( &self, signal_name: &str, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value> + 'static,
signal_name
on this object. Read moresource§fn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value> + 'static,
fn connect_local_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value> + 'static,
signal_id
on this object. Read moresource§unsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe<F>( &self, signal_name: &str, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value>,
signal_name
on this object. Read moresource§unsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value>,
signal_id
on this object. Read moresource§fn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure( &self, signal_name: &str, after: bool, closure: RustClosure ) -> SignalHandlerId
signal_name
on this object. Read moresource§fn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure_id( &self, signal_id: SignalId, details: Option<Quark>, after: bool, closure: RustClosure ) -> SignalHandlerId
signal_id
on this object. Read moresource§fn watch_closure(&self, closure: &impl AsRef<Closure>)
fn watch_closure(&self, closure: &impl AsRef<Closure>)
closure
to the lifetime of the object. When
the object’s reference count drops to zero, the closure will be
invalidated. An invalidated closure will ignore any calls to
invoke_with_values
, or
invoke
when using Rust closures.source§fn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
fn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> Rwhere R: TryFromClosureReturnValue,
source§fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
Self::emit
but takes Value
for the arguments.source§fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> Rwhere R: TryFromClosureReturnValue,
source§fn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_values( &self, signal_name: &str, args: &[Value] ) -> Option<Value>
source§fn emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_by_name_with_details<R>( &self, signal_name: &str, details: Quark, args: &[&dyn ToValue] ) -> Rwhere R: TryFromClosureReturnValue,
source§fn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_details_and_values( &self, signal_name: &str, details: Quark, args: &[Value] ) -> Option<Value>
source§fn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_with_details<R>( &self, signal_id: SignalId, details: Quark, args: &[&dyn ToValue] ) -> Rwhere R: TryFromClosureReturnValue,
source§fn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_with_details_and_values( &self, signal_id: SignalId, details: Quark, args: &[Value] ) -> Option<Value>
source§fn disconnect(&self, handler_id: SignalHandlerId)
fn disconnect(&self, handler_id: SignalHandlerId)
source§fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: Fn(&T, &ParamSpec) + Send + Sync + 'static,
fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere F: Fn(&T, &ParamSpec) + Send + Sync + 'static,
notify
signal of the object. Read moresource§fn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: Fn(&T, &ParamSpec) + 'static,
fn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere F: Fn(&T, &ParamSpec) + 'static,
notify
signal of the object. Read moresource§unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerIdwhere
F: Fn(&T, &ParamSpec),
unsafe fn connect_notify_unsafe<F>( &self, name: Option<&str>, f: F ) -> SignalHandlerIdwhere F: Fn(&T, &ParamSpec),
notify
signal of the object. Read moresource§fn notify(&self, property_name: &str)
fn notify(&self, property_name: &str)
source§fn notify_by_pspec(&self, pspec: &ParamSpec)
fn notify_by_pspec(&self, pspec: &ParamSpec)
source§fn add_weak_ref_notify<F>(&self, f: F) -> WeakRefNotify<T>where
F: FnOnce() + Send + 'static,
fn add_weak_ref_notify<F>(&self, f: F) -> WeakRefNotify<T>where F: FnOnce() + Send + 'static,
source§fn add_weak_ref_notify_local<F>(&self, f: F) -> WeakRefNotify<T>where
F: FnOnce() + 'static,
fn add_weak_ref_notify_local<F>(&self, f: F) -> WeakRefNotify<T>where F: FnOnce() + 'static,
source§fn bind_property<'f, 't, O, 'a>(
&'a self,
source_property: &'a str,
target: &'a O,
target_property: &'a str
) -> BindingBuilder<'a, 'f, 't>where
O: ObjectType,
fn bind_property<'f, 't, O, 'a>( &'a self, source_property: &'a str, target: &'a O, target_property: &'a str ) -> BindingBuilder<'a, 'f, 't>where O: ObjectType,
source§unsafe fn run_dispose(&self)
unsafe fn run_dispose(&self)
source§impl<T> PropertyGet for Twhere
T: HasParamSpec,
impl<T> PropertyGet for Twhere T: HasParamSpec,
source§impl<O> SocketExt for Owhere
O: IsA<Socket>,
impl<O> SocketExt for Owhere O: IsA<Socket>,
source§fn close(&self) -> Result<(), Error>
fn close(&self) -> Result<(), Error>
source§fn condition_check(&self, condition: IOCondition) -> IOCondition
fn condition_check(&self, condition: IOCondition) -> IOCondition
self
to perform operations.
The operations specified in condition
are checked for and masked
against the currently-satisfied conditions on self
. The result
is returned. Read moresource§fn condition_timed_wait(
&self,
condition: IOCondition,
timeout_us: i64,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>
fn condition_timed_wait( &self, condition: IOCondition, timeout_us: i64, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(), Error>
source§fn condition_wait(
&self,
condition: IOCondition,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>
fn condition_wait( &self, condition: IOCondition, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(), Error>
source§fn connect(
&self,
address: &impl IsA<SocketAddress>,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>
fn connect( &self, address: &impl IsA<SocketAddress>, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(), Error>
source§fn available_bytes(&self) -> isize
fn available_bytes(&self) -> isize
source§fn is_blocking(&self) -> bool
fn is_blocking(&self) -> bool
set_blocking()
. Read moresource§fn is_broadcast(&self) -> bool
fn is_broadcast(&self) -> bool
source§fn credentials(&self) -> Result<Credentials, Error>
fn credentials(&self) -> Result<Credentials, Error>
SocketFamily::Unix
sockets). Read moresource§fn family(&self) -> SocketFamily
fn family(&self) -> SocketFamily
source§fn is_keepalive(&self) -> bool
fn is_keepalive(&self) -> bool
set_keepalive()
. Read moresource§fn listen_backlog(&self) -> i32
fn listen_backlog(&self) -> i32
set_listen_backlog()
. Read moresource§fn local_address(&self) -> Result<SocketAddress, Error>
fn local_address(&self) -> Result<SocketAddress, Error>
source§fn is_multicast_loopback(&self) -> bool
fn is_multicast_loopback(&self) -> bool
source§fn multicast_ttl(&self) -> u32
fn multicast_ttl(&self) -> u32
self
; see
set_multicast_ttl()
for more details. Read moresource§fn option(&self, level: i32, optname: i32) -> Result<i32, Error>
fn option(&self, level: i32, optname: i32) -> Result<i32, Error>
self
, as with
getsockopt()
. (If you need to fetch a non-integer-valued option,
you will need to call getsockopt()
directly.) Read moresource§fn protocol(&self) -> SocketProtocol
fn protocol(&self) -> SocketProtocol
source§fn remote_address(&self) -> Result<SocketAddress, Error>
fn remote_address(&self) -> Result<SocketAddress, Error>
source§fn socket_type(&self) -> SocketType
fn socket_type(&self) -> SocketType
source§fn timeout(&self) -> u32
fn timeout(&self) -> u32
set_timeout()
. Read moresource§fn is_connected(&self) -> bool
fn is_connected(&self) -> bool
source§fn join_multicast_group(
&self,
group: &impl IsA<InetAddress>,
source_specific: bool,
iface: Option<&str>
) -> Result<(), Error>
fn join_multicast_group( &self, group: &impl IsA<InetAddress>, source_specific: bool, iface: Option<&str> ) -> Result<(), Error>
self
to receive multicast messages sent to group
.
self
must be a SocketType::Datagram
socket, and must have
been bound to an appropriate interface and port with
bind()
. Read moresource§fn join_multicast_group_ssm(
&self,
group: &impl IsA<InetAddress>,
source_specific: Option<&impl IsA<InetAddress>>,
iface: Option<&str>
) -> Result<(), Error>
fn join_multicast_group_ssm( &self, group: &impl IsA<InetAddress>, source_specific: Option<&impl IsA<InetAddress>>, iface: Option<&str> ) -> Result<(), Error>
self
to receive multicast messages sent to group
.
self
must be a SocketType::Datagram
socket, and must have
been bound to an appropriate interface and port with
bind()
. Read moresource§fn leave_multicast_group(
&self,
group: &impl IsA<InetAddress>,
source_specific: bool,
iface: Option<&str>
) -> Result<(), Error>
fn leave_multicast_group( &self, group: &impl IsA<InetAddress>, source_specific: bool, iface: Option<&str> ) -> Result<(), Error>
self
from the multicast group defined by group
, iface
,
and source_specific
(which must all have the same values they had
when you joined the group). Read moresource§fn leave_multicast_group_ssm(
&self,
group: &impl IsA<InetAddress>,
source_specific: Option<&impl IsA<InetAddress>>,
iface: Option<&str>
) -> Result<(), Error>
fn leave_multicast_group_ssm( &self, group: &impl IsA<InetAddress>, source_specific: Option<&impl IsA<InetAddress>>, iface: Option<&str> ) -> Result<(), Error>
self
from the multicast group defined by group
, iface
,
and source_specific
(which must all have the same values they had
when you joined the group). Read moresource§fn set_blocking(&self, blocking: bool)
fn set_blocking(&self, blocking: bool)
IOErrorEnum::WouldBlock
error. Read moresource§fn set_broadcast(&self, broadcast: bool)
fn set_broadcast(&self, broadcast: bool)
source§fn set_keepalive(&self, keepalive: bool)
fn set_keepalive(&self, keepalive: bool)
SO_KEEPALIVE
flag on the underlying socket. When
this flag is set on a socket, the system will attempt to verify that the
remote socket endpoint is still present if a sufficiently long period of
time passes with no data being exchanged. If the system is unable to
verify the presence of the remote endpoint, it will automatically close
the connection. Read moresource§fn set_listen_backlog(&self, backlog: i32)
fn set_listen_backlog(&self, backlog: i32)
source§fn set_multicast_loopback(&self, loopback: bool)
fn set_multicast_loopback(&self, loopback: bool)
source§fn set_multicast_ttl(&self, ttl: u32)
fn set_multicast_ttl(&self, ttl: u32)
self
.
By default, this is 1, meaning that multicast packets will not leave
the local network. Read moresource§fn set_option(&self, level: i32, optname: i32, value: i32) -> Result<(), Error>
fn set_option(&self, level: i32, optname: i32, value: i32) -> Result<(), Error>
self
, as with
setsockopt()
. (If you need to set a non-integer-valued option,
you will need to call setsockopt()
directly.) Read moresource§fn set_timeout(&self, timeout: u32)
fn set_timeout(&self, timeout: u32)
self
will
time out if they have not yet completed. Read moresource§fn set_ttl(&self, ttl: u32)
fn set_ttl(&self, ttl: u32)
self
.
By default the platform-specific default value is used. Read moresource§fn shutdown(
&self,
shutdown_read: bool,
shutdown_write: bool
) -> Result<(), Error>
fn shutdown( &self, shutdown_read: bool, shutdown_write: bool ) -> Result<(), Error>
source§fn speaks_ipv4(&self) -> bool
fn speaks_ipv4(&self) -> bool
fn type_(&self) -> SocketType
fn connect_blocking_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,
fn connect_broadcast_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,
fn connect_keepalive_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,
fn connect_listen_backlog_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,
fn connect_local_address_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,
fn connect_multicast_loopback_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,
fn connect_multicast_ttl_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,
fn connect_remote_address_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,
fn connect_timeout_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,
fn connect_ttl_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,
source§impl<O> SocketExtManual for Owhere
O: IsA<Socket>,
impl<O> SocketExtManual for Owhere O: IsA<Socket>,
source§fn receive<B, C>(
&self,
buffer: B,
cancellable: Option<&C>
) -> Result<usize, Error>where
B: AsMut<[u8]>,
C: IsA<Cancellable>,
fn receive<B, C>( &self, buffer: B, cancellable: Option<&C> ) -> Result<usize, Error>where B: AsMut<[u8]>, C: IsA<Cancellable>,
size
bytes) from a socket. This is mainly used by
connection-oriented sockets; it is identical to SocketExtManual::receive_from()
with address
set to None
. Read moresource§fn receive_from<B, C>(
&self,
buffer: B,
cancellable: Option<&C>
) -> Result<(usize, SocketAddress), Error>where
B: AsMut<[u8]>,
C: IsA<Cancellable>,
fn receive_from<B, C>( &self, buffer: B, cancellable: Option<&C> ) -> Result<(usize, SocketAddress), Error>where B: AsMut<[u8]>, C: IsA<Cancellable>,
size
bytes) from a socket. Read moresource§fn receive_message<C>(
&self,
address: Option<&mut Option<SocketAddress>>,
vectors: &mut [InputVector<'_>],
control_messages: Option<&mut SocketControlMessages>,
flags: i32,
cancellable: Option<&C>
) -> Result<(usize, i32), Error>where
C: IsA<Cancellable>,
fn receive_message<C>( &self, address: Option<&mut Option<SocketAddress>>, vectors: &mut [InputVector<'_>], control_messages: Option<&mut SocketControlMessages>, flags: i32, cancellable: Option<&C> ) -> Result<(usize, i32), Error>where C: IsA<Cancellable>,
SocketExtManual::receive_messages()
; for easier use, see
SocketExtManual::receive()
and SocketExtManual::receive_from()
. Read moresource§fn receive_messages<C>(
&self,
messages: &mut [InputMessage<'_>],
flags: i32,
cancellable: Option<&C>
) -> Result<usize, Error>where
C: IsA<Cancellable>,
fn receive_messages<C>( &self, messages: &mut [InputMessage<'_>], flags: i32, cancellable: Option<&C> ) -> Result<usize, Error>where C: IsA<Cancellable>,
self
in one go. This is the most
complicated and fully-featured version of this call. For easier use, see
SocketExtManual::receive()
, SocketExtManual::receive_from()
, and SocketExtManual::receive_message()
. Read moresource§fn receive_with_blocking<B, C>(
&self,
buffer: B,
blocking: bool,
cancellable: Option<&C>
) -> Result<usize, Error>where
B: AsMut<[u8]>,
C: IsA<Cancellable>,
fn receive_with_blocking<B, C>( &self, buffer: B, blocking: bool, cancellable: Option<&C> ) -> Result<usize, Error>where B: AsMut<[u8]>, C: IsA<Cancellable>,
SocketExtManual::receive()
, except that
the choice of blocking or non-blocking behavior is determined by
the blocking
argument rather than by self
’s properties. Read moresource§fn send<B, C>(&self, buffer: B, cancellable: Option<&C>) -> Result<usize, Error>where
B: AsRef<[u8]>,
C: IsA<Cancellable>,
fn send<B, C>(&self, buffer: B, cancellable: Option<&C>) -> Result<usize, Error>where B: AsRef<[u8]>, C: IsA<Cancellable>,
size
bytes from buffer
on the socket. This is
mainly used by connection-oriented sockets; it is identical to
SocketExtManual::send_to()
with address
set to None
. Read moresource§fn send_message<P, C>(
&self,
address: Option<&P>,
vectors: &[OutputVector<'_>],
messages: &[SocketControlMessage],
flags: i32,
cancellable: Option<&C>
) -> Result<usize, Error>where
P: IsA<SocketAddress>,
C: IsA<Cancellable>,
fn send_message<P, C>( &self, address: Option<&P>, vectors: &[OutputVector<'_>], messages: &[SocketControlMessage], flags: i32, cancellable: Option<&C> ) -> Result<usize, Error>where P: IsA<SocketAddress>, C: IsA<Cancellable>,
address
on self
. For sending multiple messages see
SocketExtManual::send_messages()
; for easier use, see
SocketExtManual::send()
and SocketExtManual::send_to()
. Read moresource§fn send_message_with_timeout<P, C>(
&self,
address: Option<&P>,
vectors: &[OutputVector<'_>],
messages: &[SocketControlMessage],
flags: i32,
timeout: Option<Duration>,
cancellable: Option<&C>
) -> Result<(PollableReturn, usize), Error>where
P: IsA<SocketAddress>,
C: IsA<Cancellable>,
fn send_message_with_timeout<P, C>( &self, address: Option<&P>, vectors: &[OutputVector<'_>], messages: &[SocketControlMessage], flags: i32, timeout: Option<Duration>, cancellable: Option<&C> ) -> Result<(PollableReturn, usize), Error>where P: IsA<SocketAddress>, C: IsA<Cancellable>,
v2_60
only.SocketExtManual::send_message()
, except that
the choice of timeout behavior is determined by the timeout_us
argument
rather than by self
’s properties. Read moresource§fn send_messages<C>(
&self,
messages: &mut [OutputMessage<'_>],
flags: i32,
cancellable: Option<&C>
) -> Result<usize, Error>where
C: IsA<Cancellable>,
fn send_messages<C>( &self, messages: &mut [OutputMessage<'_>], flags: i32, cancellable: Option<&C> ) -> Result<usize, Error>where C: IsA<Cancellable>,
self
in one go. This is the most
complicated and fully-featured version of this call. For easier use, see
SocketExtManual::send()
, SocketExtManual::send_to()
, and SocketExtManual::send_message()
. Read moresource§fn send_to<B, P, C>(
&self,
address: Option<&P>,
buffer: B,
cancellable: Option<&C>
) -> Result<usize, Error>where
B: AsRef<[u8]>,
P: IsA<SocketAddress>,
C: IsA<Cancellable>,
fn send_to<B, P, C>( &self, address: Option<&P>, buffer: B, cancellable: Option<&C> ) -> Result<usize, Error>where B: AsRef<[u8]>, P: IsA<SocketAddress>, C: IsA<Cancellable>,
size
bytes from buffer
to address
. If address
is
None
then the message is sent to the default receiver (set by
SocketExt::connect()
). Read moresource§fn send_with_blocking<B, C>(
&self,
buffer: B,
blocking: bool,
cancellable: Option<&C>
) -> Result<usize, Error>where
B: AsRef<[u8]>,
C: IsA<Cancellable>,
fn send_with_blocking<B, C>( &self, buffer: B, blocking: bool, cancellable: Option<&C> ) -> Result<usize, Error>where B: AsRef<[u8]>, C: IsA<Cancellable>,
SocketExtManual::send()
, except that
the choice of blocking or non-blocking behavior is determined by
the blocking
argument rather than by self
’s properties. Read more