oracle/oci_attr/handle.rs
1// Rust-oracle - Rust binding for Oracle database
2//
3// URL: https://github.com/kubo/rust-oracle
4//
5//-----------------------------------------------------------------------------
6// Copyright (c) 2017-2021 Kubo Takehiro <kubo@jiubao.org>. All rights reserved.
7// This program is free software: you can modify it and/or redistribute it
8// under the terms of:
9//
10// (i) the Universal Permissive License v 1.0 or at your option, any
11// later version (http://oss.oracle.com/licenses/upl); and/or
12//
13// (ii) the Apache License v 2.0. (http://www.apache.org/licenses/LICENSE-2.0)
14//-----------------------------------------------------------------------------
15
16//! The module defines types to be set to the associate type [`OciAttr::HandleType`]
17#[cfg(doc)]
18use crate::oci_attr::OciAttr;
19use crate::private;
20#[cfg(doc)]
21use crate::Connection;
22use odpic_sys::dpi_impl::{DPI_OCI_HTYPE_SERVER, DPI_OCI_HTYPE_SESSION, DPI_OCI_HTYPE_SVCCTX};
23
24/// OCI handle type to restrict the associate type [`OciAttr::HandleType`]
25///
26/// By using the [sealed trait pattern], no types outside of the `oracle` crate implement this.
27///
28/// [sealed trait pattern]: https://rust-lang.github.io/api-guidelines/future-proofing.html#c-sealed
29pub trait HandleType: private::Sealed {}
30
31/// OCI handle type related to `Connection` to restrict the type parameters of [`Connection::oci_attr`] and [`Connection::set_oci_attr`]
32pub trait ConnHandle: HandleType {
33 #[doc(hidden)]
34 const HANDLE_TYPE: u32;
35}
36
37/// [`HandleType`] for [Service Context Handle Attributes]
38///
39/// [service context handle attributes]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-D8EE68EB-7E38-4068-B06E-DF5686379E5E
40#[derive(Debug)]
41pub struct SvcCtx {
42 _unused: [usize; 0],
43}
44impl private::Sealed for SvcCtx {}
45impl HandleType for SvcCtx {}
46impl ConnHandle for SvcCtx {
47 #[doc(hidden)]
48 const HANDLE_TYPE: u32 = DPI_OCI_HTYPE_SVCCTX;
49}
50
51/// [`HandleType`] for [Server Handle Attributes]
52///
53/// [server handle attributes]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-2B6D06A7-8EDF-46FF-BDEF-320D293DCA65
54#[derive(Debug)]
55pub struct Server {
56 _unused: [usize; 0],
57}
58impl private::Sealed for Server {}
59impl HandleType for Server {}
60impl ConnHandle for Server {
61 #[doc(hidden)]
62 const HANDLE_TYPE: u32 = DPI_OCI_HTYPE_SERVER;
63}
64
65/// [`HandleType`] for [Authentication Information Handle Attributes] and [User Session Handle Attributes]
66///
67/// [authentication information handle attributes]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-0193473A-20FE-4727-850E-41269F94BAD4
68/// [user session handle attributes]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-FB263210-118E-4DB3-A840-1769EF0CB977
69#[derive(Debug)]
70pub struct Session {
71 _unused: [usize; 0],
72}
73impl private::Sealed for Session {}
74impl HandleType for Session {}
75impl ConnHandle for Session {
76 #[doc(hidden)]
77 const HANDLE_TYPE: u32 = DPI_OCI_HTYPE_SESSION;
78}
79
80/// [`HandleType`] for [Statement Handle Attributes]
81///
82/// [statement handle attributes]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-A251CF91-EB9F-4DBC-8BB8-FB5EA92C20DE
83#[derive(Debug)]
84pub struct Stmt {
85 _unused: [usize; 0],
86}
87impl private::Sealed for Stmt {}
88impl HandleType for Stmt {}