pub struct ItemGroup { /* private fields */ }Expand description
Which items a subscription covers.
The protocol sends a single LS_group string and lets the server’s
Metadata Adapter decide what it names
[docs/spec/03-requests.md §6.1]. In practice adapters use one of two
conventions, and this type supports both:
- a group name the adapter knows, resolved server-side into a list;
- a literal list of item names separated by spaces, which is what the stock adapters and the public demo server accept.
§Examples
use lightstreamer_rs::ItemGroup;
let listed = ItemGroup::from_items(["item1", "item2", "item3"])?;
assert_eq!(listed.as_str(), "item1 item2 item3");
let named = ItemGroup::try_new("portfolio1")?;
assert_eq!(named.as_str(), "portfolio1");Implementations§
Source§impl ItemGroup
impl ItemGroup
Sourcepub fn try_new(group: impl Into<String>) -> Result<Self, ConfigError>
pub fn try_new(group: impl Into<String>) -> Result<Self, ConfigError>
Wraps a group name the server’s Metadata Adapter will resolve.
§Errors
ConfigError::EmptyItemGroupif the name is empty or only whitespace.ConfigError::ItemGroupControlCharacterif it contains an ASCII control character. A guard of this crate: the specification gives no grammar for the name, but a control character in one is always a mistake.
Sourcepub fn from_items<I, S>(items: I) -> Result<Self, ConfigError>
pub fn from_items<I, S>(items: I) -> Result<Self, ConfigError>
Builds the space-separated list convention from individual item names.
§Errors
ConfigError::EmptyItemGroupif the iterator is empty.ConfigError::ItemNameHasWhitespaceif any name contains whitespace, which would make it two items once joined.ConfigError::ItemGroupControlCharacterif any name contains an ASCII control character.
§Examples
use lightstreamer_rs::{ConfigError, ItemGroup};
assert!(matches!(
ItemGroup::from_items(["two words"]),
Err(ConfigError::ItemNameHasWhitespace { .. })
));Sourcepub fn names(&self) -> Vec<&str>
pub fn names(&self) -> Vec<&str>
The item names, when the caller spelled them out.
Empty for a group name the server resolves: TLCP never transmits item
names, so this crate cannot know them and reports each item by its
1-based position instead [docs/spec/04-notifications.md §3.1].
§Examples
use lightstreamer_rs::ItemGroup;
assert_eq!(ItemGroup::from_items(["a", "b"])?.names(), vec!["a", "b"]);
assert!(ItemGroup::try_new("portfolio1")?.names().is_empty());Trait Implementations§
impl Eq for ItemGroup
Source§impl Ord for ItemGroup
impl Ord for ItemGroup
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for ItemGroup
impl PartialOrd for ItemGroup
impl StructuralPartialEq for ItemGroup
Auto Trait Implementations§
impl Freeze for ItemGroup
impl RefUnwindSafe for ItemGroup
impl Send for ItemGroup
impl Sync for ItemGroup
impl Unpin for ItemGroup
impl UnsafeUnpin for ItemGroup
impl UnwindSafe for ItemGroup
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more