snapshot commands implemented

This commit is contained in:
2026-02-06 17:31:41 +00:00
parent 27922d41bb
commit 4db173154b
2 changed files with 95 additions and 14 deletions

View File

@@ -16,7 +16,7 @@ func NewSnapshot(c *Client) *Snapshot {
// Name gets the name of the snapshot at the given index.
func (s *Snapshot) Name(index int) (string, error) {
address := s.baseAddress + fmt.Sprintf("/name/%d", index)
address := s.baseAddress + fmt.Sprintf("/%02d/name", index)
err := s.client.SendMessage(address)
if err != nil {
return "", err
@@ -35,24 +35,30 @@ func (s *Snapshot) Name(index int) (string, error) {
// SetName sets the name of the snapshot at the given index.
func (s *Snapshot) SetName(index int, name string) error {
address := s.baseAddress + fmt.Sprintf("/name/%d", index)
address := s.baseAddress + fmt.Sprintf("/%02d/name", index)
return s.client.SendMessage(address, name)
}
// Load loads the snapshot at the given index.
func (s *Snapshot) Load(index int) error {
address := s.baseAddress + fmt.Sprintf("/load/%d", index)
return s.client.SendMessage(address)
// CurrentName sets the name of the current snapshot.
func (s *Snapshot) CurrentName(name string) error {
address := s.baseAddress + "/name"
return s.client.SendMessage(address, name)
}
// Save saves the current state to the snapshot at the given index.
func (s *Snapshot) Save(index int) error {
address := s.baseAddress + fmt.Sprintf("/save/%d", index)
return s.client.SendMessage(address)
// CurrentLoad loads the snapshot at the given index.
func (s *Snapshot) CurrentLoad(index int) error {
address := s.baseAddress + "/load"
return s.client.SendMessage(address, int32(index))
}
// Delete deletes the snapshot at the given index.
func (s *Snapshot) Delete(index int) error {
address := s.baseAddress + fmt.Sprintf("/delete/%d", index)
return s.client.SendMessage(address)
// CurrentSave saves the current state to the snapshot at the given index.
func (s *Snapshot) CurrentSave(index int) error {
address := s.baseAddress + "/save"
return s.client.SendMessage(address, int32(index))
}
// CurrentDelete deletes the snapshot at the given index.
func (s *Snapshot) CurrentDelete(index int) error {
address := s.baseAddress + "/delete"
return s.client.SendMessage(address, int32(index))
}