#[non_exhaustive]pub enum Message {
Show 16 variants
Hello(Hello),
HelloReply(HelloReply),
Have(Vec<ObjectName>),
HaveReply(HaveReply),
ObjectHeader(ObjectHeader),
ObjectsEnd,
ObjectsReply(ObjectsReply),
Commit(CommitRequest),
CommitReply(Vec<RefOutcome>),
Error(ErrorMessage),
Abort,
PullHello(PullHello),
PullHelloReply(PullHelloReply),
Get(String),
GetReply(GetReply),
ListRefs(ListRefsRequest),
}Expand description
A message of the push or the pull protocol.
A later protocol version can add messages.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Hello(Hello)
The Hello message.
HelloReply(HelloReply)
The HelloReply message.
Have(Vec<ObjectName>)
The Have message, with the objects that the client offers.
Each object is of type 1 to 4.
HaveReply(HaveReply)
The HaveReply message.
ObjectHeader(ObjectHeader)
The ObjectHeader message.
ObjectsEnd
The ObjectsEnd message.
ObjectsReply(ObjectsReply)
The ObjectsReply message.
Commit(CommitRequest)
The Commit message.
CommitReply(Vec<RefOutcome>)
The CommitReply message, with one outcome for each ref update, or
for each ref of a ServerCommit.
Error(ErrorMessage)
The Error message.
Abort
The Abort message.
PullHello(PullHello)
The PullHello message.
PullHelloReply(PullHelloReply)
The PullHelloReply message.
Get(String)
The Get message, with the path of one file.
The path is relative to the repository root.
GetReply(GetReply)
The GetReply message.
ListRefs(ListRefsRequest)
The ListRefs message, with the entries of a ref listing request.
Implementations§
Source§impl Message
impl Message
Sourcepub fn encode_body(&self) -> Result<Vec<u8>>
pub fn encode_body(&self) -> Result<Vec<u8>>
Encodes the body of the message, with no frame length and no kind byte.
§Errors
Error::Protocol if the message holds a value that it cannot carry:
- a
HelloReplywhosemax_frame,max_have, orparallel_uploadsis out of range - a
Haveentry or amissingobject of a type other than 1 to 4, for example type 6 - an
ObjectHeaderof a type other than 1 to 4 and 6, or withEncoding::Deflatefor an object that is not a file - an
Errormessage with the coderef-mismatchand nocurrentstate - a
GetReplywhosefoundisfalseand that has a length - a metadata entry of a
ServerCommitwhose bytes are not avin normal form - a string with an interior NUL byte, which the GVariant serializer refuses
Sourcepub fn decode(kind: Kind, body: &[u8]) -> Result<Message>
pub fn decode(kind: Kind, body: &[u8]) -> Result<Message>
Decodes the body of a message of kind.
The decoder borrows strings and byte arrays from body and reads each
array one entry at a time. It allocates the decoded message. It checks
a dict value under a key that it does not know for normal form in
place, with no value tree, and then drops it. If a dict holds a key
two times, the first value counts, and the decoder checks each later
value for normal form alone. It checks each metadata entry of a
server commit in place and copies its bytes, with no value tree.
MAX_FRAME states the measured peaks.
§Errors
Error::Protocol if the body is malformed:
- the body is not in normal form for the type of
kind - an
ObjectsEndbody is not empty, or anAbortbody is not the one byte0x00 - a known dict key holds a value of the wrong type
- a
HelloReplyhas nomode,max-frame,max-have,encodings, orparallel-uploadskey, or a limit is out of range - a checksum is not 32 bytes long
- an object type or an encoding byte is not allowed in the message
- a ref update of a
Commithas an unknown expected state, or a state that does not match its expected commit - the value under
server-commitof aCommit, or undertimestampororphanof its options, has the wrong type - an attachment of a server commit has an empty name
- an
Errormessage has an unknown code, has one of the keysrefandcurrentalone, or has the coderef-mismatchwith neither - a
GetReplywhosefoundisfalsehas a length
Trait Implementations§
impl Eq for Message
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Forget for Message
impl Freeze for Messagewhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
PhantomData<Encoding>: Freeze,
PhantomData<RefState>: Freeze,
PhantomData<ObjectName>: Freeze,
PhantomData<RefUpdate>: Freeze,
*const ServerCommit is !null: Freeze,
PhantomData<ServerCommit>: Freeze,
PhantomData<RefOutcome>: Freeze,
impl Move for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Messagewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<Encoding>: UnsafeUnpin,
PhantomData<RefState>: UnsafeUnpin,
PhantomData<ObjectName>: UnsafeUnpin,
PhantomData<RefUpdate>: UnsafeUnpin,
*const ServerCommit is !null: UnsafeUnpin,
PhantomData<ServerCommit>: UnsafeUnpin,
PhantomData<RefOutcome>: UnsafeUnpin,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.