Struct gio::Socket

source ·
#[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

source

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().

source

pub unsafe fn from_socket(socket: impl IntoRawSocket) -> Result<Socket, Error>

source§

impl Socket

source

pub const NONE: Option<&'static Socket> = None

source

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 AsRawFd for Socket

source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
source§

impl Clone for Socket

source§

fn clone(&self) -> Self

Returns a copy 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 Socket

source§

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

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

impl Display for Socket

source§

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

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

impl HasParamSpec for Socket

§

type ParamSpec = ParamSpecObject

§

type SetValue = Socket

Preferred value to be used as setter for the associated ParamSpec.
§

type BuilderFn = fn(_: &str) -> ParamSpecObjectBuilder<'_, Socket>

source§

fn param_spec_builder() -> Self::BuilderFn

source§

impl Hash for Socket

source§

fn hash<H>(&self, state: &mut H)where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Socket

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl ParentClassIs for Socket

source§

impl<OT: ObjectType> PartialEq<OT> for Socket

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<OT: ObjectType> PartialOrd<OT> for Socket

source§

fn partial_cmp(&self, other: &OT) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl StaticType for Socket

source§

fn static_type() -> Type

Returns the type identifier of Self.
source§

impl Eq for Socket

source§

impl IsA<DatagramBased> for Socket

source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> Cast for Twhere T: ObjectType,

source§

fn upcast<T>(self) -> Twhere T: ObjectType, Self: IsA<T>,

Upcasts an object to a superclass or interface T. Read more
source§

fn upcast_ref<T>(&self) -> &Twhere T: ObjectType, Self: IsA<T>,

Upcasts an object to a reference of its superclass or interface T. Read more
source§

fn downcast<T>(self) -> Result<T, Self>where T: ObjectType, Self: CanDowncast<T>,

Tries to downcast to a subclass or interface implementor T. Read more
source§

fn downcast_ref<T>(&self) -> Option<&T>where T: ObjectType, Self: CanDowncast<T>,

Tries to downcast to a reference of its subclass or interface implementor T. Read more
source§

fn dynamic_cast<T>(self) -> Result<T, Self>where T: ObjectType,

Tries to cast to an object of type 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 more
source§

fn dynamic_cast_ref<T>(&self) -> Option<&T>where T: ObjectType,

Tries to cast to reference to an object of type 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 more
source§

unsafe fn unsafe_cast<T>(self) -> Twhere T: ObjectType,

Casts to T unconditionally. Read more
source§

unsafe fn unsafe_cast_ref<T>(&self) -> &Twhere T: ObjectType,

Casts to &T unconditionally. Read more
source§

impl<O> DatagramBasedExt for Owhere O: IsA<DatagramBased>,

source§

fn condition_check(&self, condition: IOCondition) -> IOCondition

Checks on the readiness of 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 more
source§

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>,

Creates a 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 more
source§

fn create_source_future<C>( &self, condition: IOCondition, cancellable: Option<&C>, priority: Priority ) -> Pin<Box<dyn Future<Output = IOCondition> + 'static, Global>>where C: IsA<Cancellable>,

source§

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>

Waits for up to timeout microseconds for condition to become true on self. If the condition is met, true is returned. Read more
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>,

Receive one or more data messages from self in one go. Read more
source§

fn send_messages<C>( &self, messages: &mut [OutputMessage<'_>], flags: i32, timeout: Option<Duration>, cancellable: Option<&C> ) -> Result<usize, Error>where C: IsA<Cancellable>,

Send one or more data messages from self in one go. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *const GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( _: *const GPtrArray, _: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( _: *const GPtrArray, _: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *const GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( _: *const GSList, _: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( _: *const GSList, _: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

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>,

source§

unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T, Global>

source§

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>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

impl<O> InitableExt for Owhere O: IsA<Initable>,

source§

unsafe fn init( &self, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(), Error>

Initializes the object implementing the interface. Read more
source§

impl<T, U> Into<U> for Twhere 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> IntoClosureReturnValue for Twhere T: Into<Value>,

source§

impl<U> IsSubclassableExt for Uwhere U: IsClass + ParentClassIs,

source§

impl<T> ObjectExt for Twhere T: ObjectType,

source§

fn is<U>(&self) -> boolwhere U: StaticType,

Returns true if the object is an instance of (can be cast to) T.
source§

fn type_(&self) -> Type

Returns the type of the object.
source§

fn object_class(&self) -> &Class<Object>

Returns the ObjectClass of the object. Read more
source§

fn class(&self) -> &Class<T>where T: IsClass,

Returns the class of the object.
source§

fn class_of<U>(&self) -> Option<&Class<U>>where U: IsClass,

Returns the class of the object in the given type T. Read more
source§

fn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where U: IsInterface,

Returns the interface T of the object. Read more
source§

fn set_property(&self, property_name: &str, value: impl Into<Value>)

Sets the property property_name of the object to value value. Read more
source§

fn set_property_from_value(&self, property_name: &str, value: &Value)

Sets the property property_name of the object to value value. Read more
source§

fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])

Sets multiple properties of the object at once. Read more
source§

fn set_properties_from_value(&self, property_values: &[(&str, Value)])

Sets multiple properties of the object at once. Read more
source§

fn property<V>(&self, property_name: &str) -> Vwhere V: for<'b> FromValue<'b> + 'static,

Gets the property property_name of the object and cast it to the type V. Read more
source§

fn property_value(&self, property_name: &str) -> Value

Gets the property property_name of the object. Read more
source§

fn has_property(&self, property_name: &str, type_: Option<Type>) -> bool

Check if the object has a property property_name of the given type_. Read more
source§

fn property_type(&self, property_name: &str) -> Option<Type>

Get the type of the property property_name of this object. Read more
source§

fn find_property(&self, property_name: &str) -> Option<ParamSpec>

Get the ParamSpec of the property property_name of this object.
source§

fn list_properties(&self) -> PtrSlice<ParamSpec>

Return all ParamSpec of the properties of this object.
source§

fn freeze_notify(&self) -> PropertyNotificationFreezeGuard

Freeze all property notifications until the return guard object is dropped. Read more
source§

unsafe fn set_qdata<QD>(&self, key: Quark, value: QD)where QD: 'static,

Set arbitrary data on this object with the given key. Read more
source§

unsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>where QD: 'static,

Return previously set arbitrary data of this object with the given key. Read more
source§

unsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>where QD: 'static,

Retrieve previously set arbitrary data of this object with the given key. Read more
source§

unsafe fn set_data<QD>(&self, key: &str, value: QD)where QD: 'static,

Set arbitrary data on this object with the given key. Read more
source§

unsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>where QD: 'static,

Return previously set arbitrary data of this object with the given key. Read more
source§

unsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>where QD: 'static,

Retrieve previously set arbitrary data of this object with the given key. Read more
source§

fn block_signal(&self, handler_id: &SignalHandlerId)

Block a given signal handler. Read more
source§

fn unblock_signal(&self, handler_id: &SignalHandlerId)

Unblock a given signal handler.
source§

fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)

Stop emission of the currently emitted signal.
source§

fn stop_signal_emission_by_name(&self, signal_name: &str)

Stop emission of the currently emitted signal by the (possibly detailed) signal name.
source§

fn connect<F>( &self, signal_name: &str, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,

Connect to the signal signal_name on this object. Read more
source§

fn connect_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,

Connect to the signal signal_id on this object. Read more
source§

fn connect_local<F>( &self, signal_name: &str, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value> + 'static,

Connect to the signal signal_name on this object. Read more
source§

fn connect_local_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value> + 'static,

Connect to the signal signal_id on this object. Read more
source§

unsafe fn connect_unsafe<F>( &self, signal_name: &str, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value>,

Connect to the signal signal_name on this object. Read more
source§

unsafe fn connect_unsafe_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F ) -> SignalHandlerIdwhere F: Fn(&[Value]) -> Option<Value>,

Connect to the signal signal_id on this object. Read more
source§

fn connect_closure( &self, signal_name: &str, after: bool, closure: RustClosure ) -> SignalHandlerId

Connect a closure to the signal signal_name on this object. Read more
source§

fn connect_closure_id( &self, signal_id: SignalId, details: Option<Quark>, after: bool, closure: RustClosure ) -> SignalHandlerId

Connect a closure to the signal signal_id on this object. Read more
source§

fn watch_closure(&self, closure: &impl AsRef<Closure>)

Limits the lifetime of 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,

Emit signal by signal id. Read more
source§

fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>

Same as Self::emit but takes Value for the arguments.
source§

fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> Rwhere R: TryFromClosureReturnValue,

Emit signal by its name. Read more
source§

fn emit_by_name_with_values( &self, signal_name: &str, args: &[Value] ) -> Option<Value>

Emit signal by its name. Read more
source§

fn emit_by_name_with_details<R>( &self, signal_name: &str, details: Quark, args: &[&dyn ToValue] ) -> Rwhere R: TryFromClosureReturnValue,

Emit signal by its name with details. Read more
source§

fn emit_by_name_with_details_and_values( &self, signal_name: &str, details: Quark, args: &[Value] ) -> Option<Value>

Emit signal by its name with details. Read more
source§

fn emit_with_details<R>( &self, signal_id: SignalId, details: Quark, args: &[&dyn ToValue] ) -> Rwhere R: TryFromClosureReturnValue,

Emit signal by signal id with details. Read more
source§

fn emit_with_details_and_values( &self, signal_id: SignalId, details: Quark, args: &[Value] ) -> Option<Value>

Emit signal by signal id with details. Read more
source§

fn disconnect(&self, handler_id: SignalHandlerId)

Disconnect a previously connected signal handler.
source§

fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere F: Fn(&T, &ParamSpec) + Send + Sync + 'static,

Connect to the notify signal of the object. Read more
source§

fn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere F: Fn(&T, &ParamSpec) + 'static,

Connect to the notify signal of the object. Read more
source§

unsafe fn connect_notify_unsafe<F>( &self, name: Option<&str>, f: F ) -> SignalHandlerIdwhere F: Fn(&T, &ParamSpec),

Connect to the notify signal of the object. Read more
source§

fn notify(&self, property_name: &str)

Notify that the given property has changed its value. Read more
source§

fn notify_by_pspec(&self, pspec: &ParamSpec)

Notify that the given property has changed its value. Read more
source§

fn downgrade(&self) -> WeakRef<T>

Downgrade this object to a weak reference.
source§

fn add_weak_ref_notify<F>(&self, f: F) -> WeakRefNotify<T>where F: FnOnce() + Send + 'static,

Add a callback to be notified when the Object is disposed.
source§

fn add_weak_ref_notify_local<F>(&self, f: F) -> WeakRefNotify<T>where F: FnOnce() + 'static,

Add a callback to be notified when the Object is disposed. Read more
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,

Bind property source_property on this object to the target_property on the target object. Read more
source§

fn ref_count(&self) -> u32

Returns the strong reference count of this object.
source§

unsafe fn run_dispose(&self)

Runs the dispose mechanism of the object. Read more
source§

impl<T> Property for Twhere T: HasParamSpec,

§

type Value = T

source§

impl<T> PropertyGet for Twhere T: HasParamSpec,

§

type Value = T

source§

fn get<R, F>(&self, f: F) -> Rwhere F: Fn(&<T as PropertyGet>::Value) -> R,

source§

impl<O> SocketExt for Owhere O: IsA<Socket>,

source§

fn accept( &self, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<Socket, Error>

Accept incoming connections on a connection-based socket. This removes the first outstanding connection request from the listening socket and creates a Socket object for it. Read more
source§

fn bind( &self, address: &impl IsA<SocketAddress>, allow_reuse: bool ) -> Result<(), Error>

When a socket is created it is attached to an address family, but it doesn’t have an address in this family. bind() assigns the address (sometimes called name) of the socket. Read more
source§

fn check_connect_result(&self) -> Result<(), Error>

Checks and resets the pending connect error for the socket. This is used to check for errors when connect() is used in non-blocking mode. Read more
source§

fn close(&self) -> Result<(), Error>

Closes the socket, shutting down any active connection. Read more
source§

fn condition_check(&self, condition: IOCondition) -> IOCondition

Checks on the readiness of 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 more
source§

fn condition_timed_wait( &self, condition: IOCondition, timeout_us: i64, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(), Error>

Waits for up to timeout_us microseconds for condition to become true on self. If the condition is met, true is returned. Read more
source§

fn condition_wait( &self, condition: IOCondition, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(), Error>

Waits for condition to become true on self. When the condition is met, true is returned. Read more
source§

fn connect( &self, address: &impl IsA<SocketAddress>, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(), Error>

Connect the socket to the specified remote address. Read more
source§

fn connection_factory_create_connection(&self) -> SocketConnection

Creates a SocketConnection subclass of the right type for self. Read more
source§

fn available_bytes(&self) -> isize

Get the amount of data pending in the OS input buffer, without blocking. Read more
source§

fn is_blocking(&self) -> bool

Gets the blocking mode of the socket. For details on blocking I/O, see set_blocking(). Read more
source§

fn is_broadcast(&self) -> bool

Gets the broadcast setting on self; if true, it is possible to send packets to broadcast addresses. Read more
source§

fn credentials(&self) -> Result<Credentials, Error>

Returns the credentials of the foreign process connected to this socket, if any (e.g. it is only supported for SocketFamily::Unix sockets). Read more
source§

fn family(&self) -> SocketFamily

Gets the socket family of the socket. Read more
source§

fn is_keepalive(&self) -> bool

Gets the keepalive mode of the socket. For details on this, see set_keepalive(). Read more
source§

fn listen_backlog(&self) -> i32

Gets the listen backlog setting of the socket. For details on this, see set_listen_backlog(). Read more
source§

fn local_address(&self) -> Result<SocketAddress, Error>

Try to get the local address of a bound socket. This is only useful if the socket has been bound to a local address, either explicitly or implicitly when connecting. Read more
source§

fn is_multicast_loopback(&self) -> bool

Gets the multicast loopback setting on self; if true (the default), outgoing multicast packets will be looped back to multicast listeners on the same host. Read more
source§

fn multicast_ttl(&self) -> u32

Gets the multicast time-to-live setting on self; see set_multicast_ttl() for more details. Read more
source§

fn option(&self, level: i32, optname: i32) -> Result<i32, Error>

Gets the value of an integer-valued option on self, as with getsockopt(). (If you need to fetch a non-integer-valued option, you will need to call getsockopt() directly.) Read more
source§

fn protocol(&self) -> SocketProtocol

Gets the socket protocol id the socket was created with. In case the protocol is unknown, -1 is returned. Read more
source§

fn remote_address(&self) -> Result<SocketAddress, Error>

Try to get the remote address of a connected socket. This is only useful for connection oriented sockets that have been connected. Read more
source§

fn socket_type(&self) -> SocketType

Gets the socket type of the socket. Read more
source§

fn timeout(&self) -> u32

Gets the timeout setting of the socket. For details on this, see set_timeout(). Read more
source§

fn ttl(&self) -> u32

Gets the unicast time-to-live setting on self; see set_ttl() for more details. Read more
source§

fn is_closed(&self) -> bool

Checks whether a socket is closed. Read more
source§

fn is_connected(&self) -> bool

Check whether the socket is connected. This is only useful for connection-oriented sockets. Read more
source§

fn join_multicast_group( &self, group: &impl IsA<InetAddress>, source_specific: bool, iface: Option<&str> ) -> Result<(), Error>

Registers 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 more
source§

fn join_multicast_group_ssm( &self, group: &impl IsA<InetAddress>, source_specific: Option<&impl IsA<InetAddress>>, iface: Option<&str> ) -> Result<(), Error>

Registers 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 more
source§

fn leave_multicast_group( &self, group: &impl IsA<InetAddress>, source_specific: bool, iface: Option<&str> ) -> Result<(), Error>

Removes 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 more
source§

fn leave_multicast_group_ssm( &self, group: &impl IsA<InetAddress>, source_specific: Option<&impl IsA<InetAddress>>, iface: Option<&str> ) -> Result<(), Error>

Removes 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 more
source§

fn listen(&self) -> Result<(), Error>

Marks the socket as a server socket, i.e. a socket that is used to accept incoming requests using accept(). Read more
source§

fn set_blocking(&self, blocking: bool)

Sets the blocking mode of the socket. In blocking mode all operations (which don’t take an explicit blocking parameter) block until they succeed or there is an error. In non-blocking mode all functions return results immediately or with a IOErrorEnum::WouldBlock error. Read more
source§

fn set_broadcast(&self, broadcast: bool)

Sets whether self should allow sending to broadcast addresses. This is false by default. Read more
source§

fn set_keepalive(&self, keepalive: bool)

Sets or unsets the 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 more
source§

fn set_listen_backlog(&self, backlog: i32)

Sets the maximum number of outstanding connections allowed when listening on this socket. If more clients than this are connecting to the socket and the application is not handling them on time then the new connections will be refused. Read more
source§

fn set_multicast_loopback(&self, loopback: bool)

Sets whether outgoing multicast packets will be received by sockets listening on that multicast address on the same host. This is true by default. Read more
source§

fn set_multicast_ttl(&self, ttl: u32)

Sets the time-to-live for outgoing multicast datagrams on self. By default, this is 1, meaning that multicast packets will not leave the local network. Read more
source§

fn set_option(&self, level: i32, optname: i32, value: i32) -> Result<(), Error>

Sets the value of an integer-valued option on self, as with setsockopt(). (If you need to set a non-integer-valued option, you will need to call setsockopt() directly.) Read more
source§

fn set_timeout(&self, timeout: u32)

Sets the time in seconds after which I/O operations on self will time out if they have not yet completed. Read more
source§

fn set_ttl(&self, ttl: u32)

Sets the time-to-live for outgoing unicast packets on self. By default the platform-specific default value is used. Read more
source§

fn shutdown( &self, shutdown_read: bool, shutdown_write: bool ) -> Result<(), Error>

Shut down part or all of a full-duplex connection. Read more
source§

fn speaks_ipv4(&self) -> bool

Checks if a socket is capable of speaking IPv4. Read more
source§

fn type_(&self) -> SocketType

source§

fn connect_blocking_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,

source§

fn connect_broadcast_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,

source§

fn connect_keepalive_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,

source§

fn connect_listen_backlog_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,

source§

fn connect_local_address_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,

source§

fn connect_multicast_loopback_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,

source§

fn connect_multicast_ttl_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,

source§

fn connect_remote_address_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,

source§

fn connect_timeout_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,

source§

fn connect_ttl_notify<F>(&self, f: F) -> SignalHandlerIdwhere F: Fn(&O) + 'static,

source§

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>,

Receive data (up to 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 more
source§

fn receive_from<B, C>( &self, buffer: B, cancellable: Option<&C> ) -> Result<(usize, SocketAddress), Error>where B: AsMut<[u8]>, C: IsA<Cancellable>,

Receive data (up to size bytes) from a socket. Read more
source§

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>,

Receive data from a socket. For receiving multiple messages, see SocketExtManual::receive_messages(); for easier use, see SocketExtManual::receive() and SocketExtManual::receive_from(). Read more
source§

fn receive_messages<C>( &self, messages: &mut [InputMessage<'_>], flags: i32, cancellable: Option<&C> ) -> Result<usize, Error>where C: IsA<Cancellable>,

Receive multiple data messages from 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 more
source§

fn receive_with_blocking<B, C>( &self, buffer: B, blocking: bool, cancellable: Option<&C> ) -> Result<usize, Error>where B: AsMut<[u8]>, C: IsA<Cancellable>,

This behaves exactly the same as 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 more
source§

fn send<B, C>(&self, buffer: B, cancellable: Option<&C>) -> Result<usize, Error>where B: AsRef<[u8]>, C: IsA<Cancellable>,

Tries to send 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 more
source§

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>,

Send data to address on self. For sending multiple messages see SocketExtManual::send_messages(); for easier use, see SocketExtManual::send() and SocketExtManual::send_to(). Read more
source§

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>,

Available on crate feature v2_60 only.
This behaves exactly the same as SocketExtManual::send_message(), except that the choice of timeout behavior is determined by the timeout_us argument rather than by self’s properties. Read more
source§

fn send_messages<C>( &self, messages: &mut [OutputMessage<'_>], flags: i32, cancellable: Option<&C> ) -> Result<usize, Error>where C: IsA<Cancellable>,

Send multiple data messages from 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 more
source§

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>,

Tries to send size bytes from buffer to address. If address is None then the message is sent to the default receiver (set by SocketExt::connect()). Read more
source§

fn send_with_blocking<B, C>( &self, buffer: B, blocking: bool, cancellable: Option<&C> ) -> Result<usize, Error>where B: AsRef<[u8]>, C: IsA<Cancellable>,

This behaves exactly the same as 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
source§

fn fd<T>(&self) -> Twhere T: FromRawFd,

Available on Unix only.
Returns the underlying OS socket object. On unix this is a socket file descriptor, and on Windows this is a Winsock2 SOCKET handle. This may be useful for doing platform specific or otherwise unusual operations on the socket. Read more
source§

fn socket<T>(&self) -> Twhere T: FromRawSocket,

Available on Windows only.
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>,

source§

fn create_source_future<C>( &self, condition: IOCondition, cancellable: Option<&C>, priority: Priority ) -> Pin<Box<dyn Future<Output = IOCondition> + 'static, Global>>where C: IsA<Cancellable>,

source§

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§

impl<T> StaticTypeExt for Twhere T: StaticType,

source§

fn ensure_type()

Ensures that the type has been registered with the type system.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T> TransparentType for Twhere T: TransparentPtrType,

source§

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

§

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> TryFromClosureReturnValue for Twhere T: for<'a> FromValue<'a> + StaticType + 'static,

source§

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

§

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.
source§

impl<Super, Sub> CanDowncast<Sub> for Superwhere Super: IsA<Super>, Sub: IsA<Super>,

source§

impl<'a, T, C, E> FromValueOptional<'a> for Twhere T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,