pub struct Identifier { /* private fields */ }Expand description
Names one subscription: a channel and the params that go with it, like the id of the record the channel streams for.
The server treats the identifier’s JSON encoding as an opaque key and echoes it back on
every frame it sends for the subscription, so the encoding has to be stable: the keys
come out sorted, channel among them.
use actioncable::Identifier;
let room = Identifier::new("RoomChannel").param("id", 42);
assert_eq!(r#"{"channel":"RoomChannel","id":42}"#, room.key());A channel with no params needs only the name.
Implementations§
Source§impl Identifier
impl Identifier
Sourcepub fn new(channel: impl Into<String>) -> Identifier
pub fn new(channel: impl Into<String>) -> Identifier
Names a channel, with no params.
Sourcepub fn param(
self,
name: impl Into<String>,
value: impl Into<Value>,
) -> Identifier
pub fn param( self, name: impl Into<String>, value: impl Into<Value>, ) -> Identifier
Adds one param, like the id of the record the channel streams for.
Sourcepub fn params(&self) -> &BTreeMap<String, Value>
pub fn params(&self) -> &BTreeMap<String, Value>
The params, sorted by name as the key encodes them.
Sourcepub fn key(&self) -> String
pub fn key(&self) -> String
The JSON string the server knows the subscription by. A param named channel loses
to the channel name.
Where the Go client returns an error, this cannot fail: a param is a
serde_json::Value, and a map of them always encodes.
Trait Implementations§
Source§impl Clone for Identifier
impl Clone for Identifier
Source§impl Debug for Identifier
impl Debug for Identifier
Source§impl Display for Identifier
impl Display for Identifier
impl Eq for Identifier
Source§impl From<Identifier> for SubscribeRequest
impl From<Identifier> for SubscribeRequest
Source§fn from(identifier: Identifier) -> SubscribeRequest
fn from(identifier: Identifier) -> SubscribeRequest
Converts to this type from the input type.
Source§impl PartialEq for Identifier
impl PartialEq for Identifier
impl StructuralPartialEq for Identifier
Auto Trait Implementations§
impl Freeze for Identifier
impl RefUnwindSafe for Identifier
impl Send for Identifier
impl Sync for Identifier
impl Unpin for Identifier
impl UnsafeUnpin for Identifier
impl UnwindSafe for Identifier
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