Skip to main content

rustorb_naming/
lib.rs

1//! CosNaming (Naming Service): NamingContext, NamingContextExt and
2//! BindingIterator, with persistence behind a storage trait.
3//!
4//! The client side: [`NamingContext`], [`NamingContextExt`] and
5//! [`BindingIterator`] are stubs for the interfaces of the CosNaming IDL
6//! (Naming Service 1.3), over the ones `rustorb-idl -brust` generates in
7//! [`idl::cos_naming`], with the names of [`rustorb_core::name`]. The user
8//! exceptions of the operations are the variants of [`NamingError`].
9//! Code generated from IDL that uses CosNaming refers to [`idl::cos_naming`]
10//! (`-Wbextern=CosNaming=rustorb_naming::idl::cos_naming`).
11//!
12//! The server side: [`NamingService`] serves the naming contexts on an
13//! ORB, with the root context at `corbaloc::host:port/NameService` like
14//! omniNames, and keeps the bindings in a [`Store`]: [`LogStore`] (an
15//! append-only log and checkpoints) by default, or [`MemoryStore`]. The
16//! `rustorb-names` binary is the daemon.
17//!
18//! ```no_run
19//! use rustorb_core::Orb;
20//! use rustorb_naming::{NamingContextExt, to_name};
21//!
22//! let mut args = vec![
23//!     "-ORBInitRef".to_owned(),
24//!     "NameService=corbaloc::localhost:2809/NameService".to_owned(),
25//! ];
26//! let orb = Orb::init(&mut args)?;
27//! let obj = orb.resolve_initial_references("NameService")?;
28//! let root = NamingContextExt::narrow(obj)?.ok_or("not a NamingContextExt")?;
29//! root.bind_new_context(&to_name("app")?)?;
30//! let echo = root.resolve_str("app/Echo")?;
31//! # Ok::<(), Box<dyn std::error::Error>>(())
32//! ```
33//!
34//! Names and their string form ([`Name`], [`to_name`], [`to_string`]) come
35//! from [`rustorb_core::name`], which `corbaname:` URLs use too:
36//! `Orb::string_to_object("corbaname::host:2809#app/Echo")` resolves the
37//! name without this crate.
38
39mod client;
40mod error;
41mod server;
42pub mod store;
43
44/// The code `rustorb-idl -brust` generates from the CosNaming IDL
45/// (`tools/generate-rust.sh` writes `src/idl/`).
46pub mod idl {
47    include!("idl/cos_naming.rs");
48}
49
50pub use client::{Binding, BindingIterator, BindingType, NamingContext, NamingContextExt, to_url};
51pub use error::{NamingError, NotFoundReason};
52pub use rustorb_core::name::{InvalidName, Name, NameComponent, to_name, to_string};
53pub use server::{NamingService, ROOT_KEY, StartError};
54pub use store::{LogStore, MemoryStore, Store};
55
56/// Repository ids of the CosNaming interfaces and exceptions.
57pub mod repository_id {
58    /// `CosNaming::NamingContext`.
59    pub const NAMING_CONTEXT: &str = "IDL:omg.org/CosNaming/NamingContext:1.0";
60    /// `CosNaming::NamingContextExt`.
61    pub const NAMING_CONTEXT_EXT: &str = "IDL:omg.org/CosNaming/NamingContextExt:1.0";
62    /// `CosNaming::BindingIterator`.
63    pub const BINDING_ITERATOR: &str = "IDL:omg.org/CosNaming/BindingIterator:1.0";
64    /// `CosNaming::NamingContext::NotFound`.
65    pub const NOT_FOUND: &str = "IDL:omg.org/CosNaming/NamingContext/NotFound:1.0";
66    /// `CosNaming::NamingContext::CannotProceed`.
67    pub const CANNOT_PROCEED: &str = "IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0";
68    /// `CosNaming::NamingContext::InvalidName`.
69    pub const INVALID_NAME: &str = "IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0";
70    /// `CosNaming::NamingContext::AlreadyBound`.
71    pub const ALREADY_BOUND: &str = "IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0";
72    /// `CosNaming::NamingContext::NotEmpty`.
73    pub const NOT_EMPTY: &str = "IDL:omg.org/CosNaming/NamingContext/NotEmpty:1.0";
74    /// `CosNaming::NamingContextExt::InvalidAddress`.
75    pub const INVALID_ADDRESS: &str = "IDL:omg.org/CosNaming/NamingContextExt/InvalidAddress:1.0";
76}