oracle/oci_attr/
mode.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::Mode`]
17#[cfg(doc)]
18use crate::oci_attr::OciAttr;
19use crate::private;
20#[cfg(doc)]
21use crate::Connection;
22#[cfg(doc)]
23use crate::Statement;
24
25/// Access mode to restrict the associate type [`OciAttr::Mode`]
26///
27/// By using the [sealed trait pattern], no types outside of the `oracle` crate implement this.
28///
29/// [sealed trait pattern]: https://rust-lang.github.io/api-guidelines/future-proofing.html#c-sealed
30pub trait Mode: private::Sealed {}
31
32/// Access mode to restrict the type parameters of [`Connection::oci_attr`] and [`Statement::oci_attr`]
33pub trait ReadMode: Mode {}
34
35/// Access mode to restrict the type parameters of [`Connection::set_oci_attr`] and [`Statement::set_oci_attr`]
36pub trait WriteMode: Mode {}
37
38/// Read only mode, which implements [`ReadMode`]
39#[derive(Debug)]
40pub struct Read;
41impl private::Sealed for Read {}
42impl Mode for Read {}
43impl ReadMode for Read {}
44
45/// Write only mode, which implements [`WriteMode`]
46#[derive(Debug)]
47pub struct Write;
48impl private::Sealed for Write {}
49impl Mode for Write {}
50impl WriteMode for Write {}
51
52/// Read write mode, which implements both [`ReadMode`] and [`WriteMode`]
53#[derive(Debug)]
54pub struct ReadWrite;
55impl private::Sealed for ReadWrite {}
56impl Mode for ReadWrite {}
57impl ReadMode for ReadWrite {}
58impl WriteMode for ReadWrite {}