// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{IOStream, Socket, SocketConnection, TcpConnection, ffi};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    #[doc(alias = "GTcpWrapperConnection")]
    pub struct TcpWrapperConnection(Object<ffi::GTcpWrapperConnection, ffi::GTcpWrapperConnectionClass>) @extends TcpConnection, SocketConnection, IOStream;

    match fn {
        type_ => || ffi::g_tcp_wrapper_connection_get_type(),
    }
}

impl TcpWrapperConnection {
    pub const NONE: Option<&'static TcpWrapperConnection> = None;

    #[doc(alias = "g_tcp_wrapper_connection_new")]
    pub fn new(
        base_io_stream: &impl IsA<IOStream>,
        socket: &impl IsA<Socket>,
    ) -> TcpWrapperConnection {
        unsafe {
            SocketConnection::from_glib_full(ffi::g_tcp_wrapper_connection_new(
                base_io_stream.as_ref().to_glib_none().0,
                socket.as_ref().to_glib_none().0,
            ))
            .unsafe_cast()
        }
    }
}

pub trait TcpWrapperConnectionExt: IsA<TcpWrapperConnection> + 'static {
    #[doc(alias = "g_tcp_wrapper_connection_get_base_io_stream")]
    #[doc(alias = "get_base_io_stream")]
    #[doc(alias = "base-io-stream")]
    fn base_io_stream(&self) -> IOStream {
        unsafe {
            from_glib_none(ffi::g_tcp_wrapper_connection_get_base_io_stream(
                self.as_ref().to_glib_none().0,
            ))
        }
    }
}

impl<O: IsA<TcpWrapperConnection>> TcpWrapperConnectionExt for O {}
