upd Name methods

This commit is contained in:
onyx-and-iris 2026-02-04 11:18:17 +00:00
parent 66ab937296
commit 49cf3ff49e

View File

@ -14,8 +14,24 @@ func NewSnapshot(c *Client) *Snapshot {
} }
} }
// Name sets the name of the snapshot at the given index. // Name gets the name of the snapshot at the given index.
func (s *Snapshot) Name(index int, name string) error { func (s *Snapshot) Name(index int) (string, error) {
address := s.baseAddress + fmt.Sprintf("/name/%d", index)
err := s.client.SendMessage(address)
if err != nil {
return "", err
}
resp := <-s.client.respChan
name, ok := resp.Arguments[0].(string)
if !ok {
return "", fmt.Errorf("unexpected argument type for snapshot name")
}
return name, nil
}
// 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("/name/%d", index)
return s.client.SendMessage(address, name) return s.client.SendMessage(address, name)
} }