pub struct Message {
pub id: Vec<u8>,
pub timestamp: u64,
pub attempts: u16,
pub body: Vec<u8>,
/* private fields */
}Expand description
NSQ消息格式
Fields§
§id: Vec<u8>唯一消息ID
timestamp: u64消息时间戳
attempts: u16消息尝试次数
body: Vec<u8>消息体
Implementations§
Source§impl Message
impl Message
Sourcepub fn with_responder(self, connection: Arc<Connection>) -> Self
pub fn with_responder(self, connection: Arc<Connection>) -> Self
设置消息响应器
Sourcepub fn disable_auto_response(&mut self)
pub fn disable_auto_response(&mut self)
禁用自动响应
调用此方法后,消息不会自动发送 FIN/REQ,需要手动调用 finish() 或 requeue()
Sourcepub fn is_auto_response_disabled(&self) -> bool
pub fn is_auto_response_disabled(&self) -> bool
检查是否禁用了自动响应
Sourcepub fn has_responded(&self) -> bool
pub fn has_responded(&self) -> bool
检查消息是否已经响应
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
从字节流解析消息
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Message
impl !RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl !UnwindSafe for Message
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