Skip to content

proposal: add vsCast method #4

@williballenthin

Description

@williballenthin

via: vivisect/dissect#1

i had used the following function to cast the bytes from one vstruct to another:

def cast_vstruct(src_instance, dst_instance):
    '''
    load the bytes that back `src_instance` into `dst_instance`.
    note that subsequent changes made to `dst_instance` are not reflected in `src_instance`.
    so this is useful in 'by-value' situations, but not for situations expecting writeback support.
    modifies `dst_instance`. does not modify src_instance.
    type src_instance: v_types.VStruct
    type dst_instance: v_types.VStruct
    '''
    d = src_instance.vsEmit()
    dst_instance.vsParse(d)

a vsCast method on vstruct might enable the passing of the fd/bytes and offset to the destination object, and therefore:

  1. be higher performant, since the serialization/deserialization is avoided.
  2. support writeback on the destination instance (though this may result in sync issues)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions